Search code examples
rubysyntax

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?


Solution

  • 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.