|
A string can be define as a group of characters.It is always enclosed between a pair of delimiter, either single quotes or double quotes.
Ruby also allows you to define other delimiters you want to use instead of the standard quotes.If you use %q, %Q, %w, %r, %x the character immediately after it will become your new delimiter.
x=%Q this_is_my_new_delimiter
This will make the blank space after %Q the new delimiter.What will be stored in x is this_is_my_new_delimiter
If we would've had it like this instead:
x=%Q this is my new delimiter
This is going to return an error.There are so many blank spaces after the first one that the Ruby does not correctly identify the end of the string.
|