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 trialCharles Strawn
3,462 Pointsexample2.rb is not working in Ruby version 2.0.0p353
Hello.
When I attempt to run the example2.rb file, I only get "Hello, world" returned. It looks as though the second puts statement is not returned.
Could it be that the instructor is running Ruby version 1.9.3, and I am running Ruby version 2.0.0p353?
def say_hello(&block)
puts "Hello, World"
name = block.call
puts = "You entered #{name} as your name."
end
say_hello { "Jason" }
1 Answer
Brandon Barrette
20,485 PointsWhat exactly are you getting? When I run this in 2.2.1 it works just fine.
Charles Strawn
3,462 PointsCharles Strawn
3,462 PointsIt just returns "Hello, World".
It does not display "You entered Jason as your name.", like it does in the video.
Brandon Barrette
20,485 PointsBrandon Barrette
20,485 PointsHuh. I'm not sure what to tell you. Upgrade your version of ruby? The current stable version of 2.0 is 2.0.0-p645 and the current stable version of ruby is 2.2.2
Charles Strawn
3,462 PointsCharles Strawn
3,462 PointsHello Brandon.
The problem with that as I see it, is the the instructor of the course is using version 1.9.3, and it works for him. It also works for you on a newer version. So this is a bit confusing.
I have also had other issues because I am using a newer version than the instructor, but I am mostly able to work around them.
My fear is that using an even newer version will make it worse.
What do you think Brandon?