Reputation: 63
I have seen different people use different types of braces/brackets for this. I tried them out in script console, and they all work. Why do they all work and does it matter which is used?
%w|one two|
%w{one two}
%w[one two]
%w(one two)
Actually, much more varaiety of characters can be used. Any non-alphanumeric character except =
can be used.
%w!a!
%w@b@
%w#c#
%w$d$
%w%e%
%w^f^
%w&g&
%w*h*
%w(i)
%w_j_
%w-k-
%w+l+
%w\m\
%w|n|
%w`o`
%w~p~
%w[q]
%w{r}
%w;s;
%w:t:
%w'u'
%w"v"
%w,w,
%w<x>
%w.y.
%w/z/
%w?aa?
Upvotes: 6
Views: 281
Reputation: 27789
No difference. The reason for the flexibility is so that you can pick delimiters that won't appear within your %w()
string.
Upvotes: 10
Reputation: 7066
There is no difference, just a personal preference for multiline strings. Some people like to use...
<<eos
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud.
eos
As long as the beginning and end are the same then you are fine.
Upvotes: 0
Reputation: 139860
You get to choose your own delimiter. Pick the one that saves you from having to escape characters.
Upvotes: 5