Can you use semicolons in Ruby?

When learning Ruby, I noticed that in all the examples there are no semicolons. I am aware that this is perfectly fine as long as each statement is on its own line. But what I am wondering is, can you use semicolons in Ruby?


Yes.

Ruby doesn't require us to use any character to separate commands, unless we want to chain multiple statements together on a single line. In this case, a semicolon (;) is used as the separator.

Source: http://articles.sitepoint.com/article/learn-ruby-on-rails/2


As a side note, it's useful to use semi-colons in your (j)irb session to avoid printing out a ridiculously long expression value, e.g.

irb[0]> x = (1..1000000000).to_a
[printout out the whole array]

vs

irb[0]> x = (1..100000000).to_a; nil

Nice especially for your MyBigORMObject.find_all calls.