This works:

language_name = "C"

case language_name
  when "C"
    puts "The language is C."
  when "Rexx"
    puts "The language is Rexx."
  else
    puts "The language is unknown"
end

So does this:

case language_name
  when "C"
    begin
      puts "The language is C."
    end
  when "Rexx"
    begin
      puts "The language is Rexx."
    end
  else
    begin
      puts "The language is unknown."
    end
end

But this gives a syntax error:

case language_name
  when "C"
    do
      puts "The language is C."
    end
  when "Rexx"
    do
      puts "The language is Rexx."
    end
  else
    do
      puts "The language is unknown."
    end
end

Why?  Nowhere I looked seemed to help.  What am I missing?

I know do/end isn't necessary, but why does it fail?

Thanks.

-- 
Posted via http://www.ruby-forum.com/.