Monday, June 11, 2012

Re: [Rails] Re: if else statement

On 11 June 2012 10:19, Paul McGuane <lists@ruby-forum.com> wrote:
> thanks for the tips, i cleaned up the code a bit, and used some other
> logic which produced this
>
> def win_lose_tie
>    if self.for.to_i == self.against.to_i then
>      :tie
>    elsif self.for.to_i > self.against.to_i then
>      :win
>    else
>      :lose
>    end
>  end

So you turned a Ruby two line method into a PHP 7-liner? If you prefer....

Well, as long as you see the direction the code should go, you can
always make it more "Ruby" later ;-)

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate