On Thu, Aug 16, 2012 at 1:43 PM, ajay paswan <[email protected]> wrote:
> Which one is faster?
Measure it. There is Benchmark.
> for example:
>
> if grade=="A"
> puts("you are smart")
> elsif grade=="F"
> puts("you are dumb")
> end
> ###########################Vs
> case grade
> when "A"
> puts("you are smart")
> when "B"
> puts("you are smart")
> end
SMARTNESS = {
"A" => "you are smart",
"B" => "you are dumb",
}
puts SMARTNESS[grade]
Cheers
robert
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
-- You received this message because you are subscribed to the Google Groups
ruby-talk-google group. To post to this group, send email to
[email protected]. To unsubscribe from this group, send email
to [email protected]. For more options, visit this
group at https://groups.google.com/d/forum/ruby-talk-google?hl=en