From: matt@... (matt neuburg) Date: 2008-07-12T00:00:52+09:00 Subject: Re: Beginner: if statement in one line? In addition to others answers you've received, keep in mind that you can always disambigue when multiple lines go on a single line through the use of semicolons: if 5 == 5; puts 5; end It happens that in this simple case, that isn't necessary, since Ruby lets you disambiguate with "then": if 5 == 5 then puts 5 end Or, as has been pointed out, you can use the end-of-line "if" operator: puts 5 if 5 == 5 m. Chris Chris wrote: > Hi, > > a simple question, however I did not find an answer for this: > > How can I put a statement like > > if 5 == 5 > puts '5' > end > > in one line? > > Just writing them all statements together in one line didn't work, > and a syntax like if 5 == 5 {puts '5'} end didn't either. > > Thanks for your help. > > CHeers, CHris -- matt neuburg, phd = matt@tidbits.com, http://www.tidbits.com/matt/ Leopard - http://www.takecontrolbooks.com/leopard-customizing.html AppleScript - http://www.amazon.com/gp/product/0596102119 Read TidBITS! It's free and smart. http://www.tidbits.com