From: Paul McMahon Date: 2007-10-22T10:35:32+09:00 Subject: Re: gsub does not work with do/end block, only brackets Braces have high precedence, do end has low precedence so with puts "abcdefg".gsub(/abc/) do |x| x.upcase end puts is being passed the block, whereas in puts "abcdefg".gsub(/abc/) { |x| x.upcase } gsub is being passed the block. If you want to use do end, you can do something like puts("abcdefg".gsub(/abc/) do |x| x.upcase end) or s = "abcdefg".gsub(/abc/) do |x| x.upcase end puts s