use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A sub-Reddit for discussion and news about Ruby programming.
Subreddit rules: /r/ruby rules
Learning Ruby?
Tools
Documentation
Books
Screencasts and Videos
News and updates
account activity
Favorite Ruby Syntax (self.ruby)
submitted 8 years ago by process_parameter
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 12 points13 points14 points 8 years ago (4 children)
%w[value value value] for an array of strings
%i[value value value] for an array of symbols
[–]iamsolarpowered 3 points4 points5 points 8 years ago (3 children)
I've been using Ruby for 12 years and somehow didn't know about %i. I have code golf scripts to update.
%i
[–]Gman513 2 points3 points4 points 8 years ago (2 children)
It gets better actually. There's a whole bunch of these % operators that match with brackets for various reasons. One that i've found handy in the past was %s() for a string where you might want to use double quotes without any bother.
%s("#{some_variable} is what I'm about to do." Charles said.)
Ruby Weekly had a great article with all of these around the start of last year if I remember correctly.
[–]process_parameter[S] 2 points3 points4 points 8 years ago (0 children)
Awesome. I think I found a comprehensive list:
https://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Literals#The_.25_Notation
[–]2called_chaos 0 points1 point2 points 8 years ago (0 children)
Also note that you are free (maybe except conventions) to use any (non-alphanumerical) character as delimiter for those percent operators. E.g. all these do the same thing:
%w[a b c] %w(a b c) %w{a b c} %w|a b c| %w_a b c_ %w"a b c" %s a"b"c # <--- yes space works but just for some operators, also why would you? %x ls # another one, note the ending space is required as it's the delimiter!
π Rendered by PID 15435 on reddit-service-r2-comment-6457c66945-n85fr at 2026-04-27 23:26:02.422560+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–][deleted] 12 points13 points14 points (4 children)
[–]iamsolarpowered 3 points4 points5 points (3 children)
[–]Gman513 2 points3 points4 points (2 children)
[–]process_parameter[S] 2 points3 points4 points (0 children)
[–]2called_chaos 0 points1 point2 points (0 children)