Working with Strings
In order to do these exercises you should have read at least the chapter about [built_in_classes/strings.html].
irb try figuring out how to produce the following String:
Try using no more than two other String objects.
irb open your terminal and type
return key (
enter). To quit it (and get back
to your system shell prompt) type
exit or press
Look through the documentation for Strings.
Do you spot any interesting methods?
What do you think this will do?
$ irb > "hello".length + "world".length
Try it yourself in
Look through the documentation for Strings,
and find out how to convert the string
"1.23" into the number
If you can’t find it, google for “ruby convert string to float”.
Then also find out what method can be used to turn the string
"1" into the
1 (remember floats and integers are different kinds of numbers).
Confirm that you have found the right methods by trying them in