capitalize method

String capitalize()

Capitalizes the first letter of the string.

Returns an empty string if the original string is empty. Example: "hello".capitalize()"Hello"

Implementation

String capitalize() {
  try {
    return "${this[0].toUpperCase()}${substring(1)}";
  } catch (e) {
    return '';
  }
}