mko
mko

Reputation: 22064

What is the Ruby expression execute priority with the multiply method chain together?

What the ruby actually does for the following statement

"one" << "two" + "three" 

is

("one" << "two") + "three"

or

"one" << ("two" + "three")

Does some methods like * that have high priority than others like +, the same as it behaves in mathematic? or just is evaluated from left to right?

Upvotes: 0

Views: 93

Answers (1)

Yax
Yax

Reputation: 436

+ will be first operator. Full operator precedence table can be found here.

Upvotes: 2

Related Questions