December 2017
Intermediate to advanced
860 pages
16h 1m
English
Strings are objects that represent a stream or sequence of characters. In Ruby, we can assign a string value to a variable with ease as seen in the previous example. By simply defining the value in quotation marks or a single quotation mark, we can assign a value to a string.
It is recommended to use double quotation marks because if single quotations are used, it can create problems. Let's have a look at the problem that may arise:
irb(main):005:0> name = 'Msf Book'
=> "Msf Book"
irb(main):006:0> name = 'Msf's Book'
irb(main):007:0' '
We can see that when we used a single quotation mark, it worked. However, when we tried to put Msf's instead of the value Msf, an error occurred. This is because it read the single quotation ...
Read now
Unlock full access