Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are different delimiters used in percent notation?

Tags:

ruby

literals

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?
like image 528
Sarah Avatar asked May 29 '11 18:05

Sarah


People also ask

Why do French use commas instead of decimal points?

In France, the full stop was already in use in printing to make Roman numerals more readable, so the comma was chosen. Many other countries, such as Italy, also chose to use the comma to mark the decimal units position.

Why does Europe use commas instead of decimal points?

In the early 1700s, Gottfried Wilhelm Leibniz, a German polymath, proposed the dot as the symbol for multiplication. Therefore, most of Europe favored the comma as a decimal separator.

What is used as a separator for decimal numbers?

Great Britain and the United States are two of the few places in the world that use a period to indicate the decimal place. Many other countries use a comma instead. The decimal separator is also called the radix character.

When would you use a thousand separator?

Thousands Separator Commas In English, you can use commas in numbers of four digits or longer (i.e., numbers above 999) after every third digit from the right. These “thousands separators” make it easier to read long numbers since we can see where the different groups of digits fall at a glance.


2 Answers

No difference. The reason for the flexibility is so that you can pick delimiters that won't appear within your %w() string.

like image 195
Mori Avatar answered Sep 20 '22 00:09

Mori


You get to choose your own delimiter. Pick the one that saves you from having to escape characters.

like image 33
hammar Avatar answered Sep 19 '22 00:09

hammar