Shannon Fang <xrfang / hotmail.com> writes: > Hi, > > The following statement will generate a syntax error: > > text.gsub!(/&#(\d+);/) do begin $1.to_i.chr rescue end; end You just have to put more semicolons in at the end of statements: text.gsub!(/&#(\d+);/) do begin $1.to_i.chr; rescue; end; end > Can anyone explain to me the general rules of when I can write code > on one line, and when I must write it on multiple lines? Maybe "statements are terminated by an end of line or a semicolon." Ruby's syntax is not "whitespace insensitive" like many other languages, but it is generally intuitive -- especially when not trying to cram too much onto one line. :-)