Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialA X
12,842 Points"Workspaces got a little funny here": Can you explain why this error produced 16?
I just watched Jason's Operator Precedence video, and he mentions at one point that "workspaces got a little funny here" and produced an interesting error(?). I'm curious if anyone can explain why this produced 16 as a result:
( * 2 * 4)
From a math perspective, I could maybe see Ruby interpreting the blank space as a 1, so 1 * 2 * 4....but that result is 8, not 16.
2 Answers
Oğulcan Girginc
24,848 PointsNormally, you would get a syntax error. It's probably just a minor problem in the workspaces.
Layla Cecil
22,310 PointsI wondered the same thing, tried it in my Mac terminal using irb, and I got a syntax error.
Girginc's thinking appears sound.
Still, weird that any environment would allow such code to play out in that way.
Maybe the code was only checking if there were two asterisks, resulting in it multiplying 2 to the 4th power?