On 5/25/09, Joshua Ballanco <jballanc / gmail.com> wrote:
> I was on a questionable connection at the time, so my original message
> may not have gotten to the mailing list:
>
>  > cat impossible.rb
>
> # This one can't be done in Pythonic style:
>
> result = case ARGV[0]
>    when /^\d*$/
>      "That's an integer!"
>    when /^[A-Za-z]*$/
>      "That looks like a word..."
>    else
>      "That's not an integer or a word."
>    end if ARGV[0]
>
> puts result if result

Yes, and it's this very sort of case that led me to make end optional
rather than forbidden in endless.rb. Clearly, some things can't be
expressed just in pythonish syntax, so you have to be able to drop
back to ruby mode. The need for more tokens on the same line after the
end is sufficiently rare that I don't think it detracts from the
overall effect; almost all ends can still be eliminated.

Actually, I think pyrb.rb also will tolerate this example as well; you
just leave off the colon and it doesn't expect to create an end for
you for that statement. Looks like it's missing the 'when' special
case, but for this example, that doesn't matter, since you have the
whens more indented anyway.