First week of Tealeaf Academy is done!
So I just finished up the last exercises for Pine’s book Learn to Program. This was part of the curriculum for the first week of Tealeaf Academy’s Introduction to Ruby and Web Development course.
I think I’ve learned more in this week than in all the other months of trying to learn programming on my own. Ruby is an awesome language to learn as it is “relatively” easy and very readable. I tried to teach myself python before taking this class so I had some programming ideas already in my head. One thing that took some getting used to was variable scope.
To illustrate what I’m talking about take a look at this code:
# Variable Scope
num1 = 13
puts "At the beginning I am: #{num1}" #num1 = 13
def change(num)
num1 = num
puts "Inside of the change method I am: #{num1} " #num1 = 47 because num1 is local inside change
end
change 47
puts "But outside of the change method I am still: #{num1}" #num1 = 13 because change did nothing to the original num1
array = ["crazy example"]
array.each do |e|
num1 = e
end
puts "But look now, I've completely changed num1 to: #{num1}" #num1 = crazy example because it was changed in array.each
and run it here: http://repl.it/OA9.
Speaking of which, two cool resources. First syntax highlighting on your wordpress blog is made pretty simple by using the Crayon Syntax Highlighter. It’s super easy to use and very customizable.
The second resource is repl.it. This lets you enter your Ruby code in and then executes it in an online version of irb (running 1.8.7, however). It’s pretty good for sharing little pieces of code with your friends and family to impress them ;)
I’m looking forward the rest of the course!