0

How can I convert a string (of one character) to character ?

Ohad
  • 1,563
  • 2
  • 20
  • 44

1 Answers1

5

You don't really have to convert it, but get it.

In Smalltalk, a String is a Collection of characters.

As for every collection, sending the first method will give you it's first component - the first Character. If you have a single-character String, that would get you that single Character.

You can send it the at: message, too, with a given index. 'Test' at: 2 would give you the $e - Collections are 1-based, at least on the Pharo version I'm testing on :)

mgarciaisaia
  • 14,521
  • 8
  • 57
  • 81