On 4/24/07, Peter Marsh <evil_grunger / hotmail.com> wrote:
> @Everyone
<snip>
> Also
>
> > @deck[@top_card] or raise "There are only 42 cards in the deck ;)"
>
> I understand what this means, but I'm unsure how to integrate this into
> my code.
If I recall correctly your code was something like

if  @top_card < 52 then
   @deck[@top_card]
else
   raise ...
end

if @top_card >=52 @deck[@top_card] evaluates to nil, as cards in the
deck are never false or nil the RHS part of the expression

@deck[@top_card] or raise ...

will be executed iff @top_card >=52.
Otherwise the LHS of the expression will be returned, exactly what you wanted.

This is very concise code, maybe even bad for readability, but worth
learning I guess.

Cheers
Robert

-- 
You see things; and you say Why?
But I dream things that never were; and I say Why not?
-- George Bernard Shaw