Ruby on Rails Friday, September 11, 2015

On Sep 11, 2015, at 9:00 AM, Nick Savage <nick.savage@gmail.com> wrote:
>
> Any help would be appreciative and the way I learn I can not move on till I know.
>
> puts "I will now count my chickens:'"
> puts "Hens #{25 + 30 / 6}"
> #how does that equal 30?
> puts "Roosters #{100 - 25 * 3 % 4}"
> #How does this equal 97
>
> puts "Now I will count the eggs:"
>
> puts 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6
> #How does this equal 7, is it because it is 6.5 and it rounds up.

Google "ruby operator precedence". Multiplication & division have higher precedence than addition & subtraction, is the answer to your immediate question. But you really should google and look at all the precedence categories.

--
Scott Ribe
scott_ribe@elevated-dev.com
http://www.elevated-dev.com/
https://www.linkedin.com/in/scottribe/
(303) 722-0567 voice





--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/4D7492A6-5DE8-4FE5-9680-ED11027B6B63%40elevated-dev.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment