A "lab" notebook where I record/reference my findings

Menu

Post navigation

T-16 to HW Due

Today I started with Ruby in 100 minutes being a Ruby newbie and installed all the things they recommended for a Mac OSX Mountain Lion system. My only hicup was with RVM which complained: mkdir: /myusername.rvm/src: Not a directory so, following a tip I found I just made the directory .rvm inside my username’s home directory (why isn’t there a slash between the myusername and the .rvm in the error message?).

Since all this installation took a while (Xcode is a 1.6 gig download, and RVM took about 15 min to install), I started looking at a git tutorial since I know nothing about it, and I figure I’ll want to be using git and github soon with all my projects.

Git by itself is a version control system, distributed in the top directories of all your projects, instead of having its own centralized storage directory.”Staging” with the git add command notifies git about the changes you’ve made to your project, without recording these changes in the repository; files need to be “added” to be “committed,” since only tracked files are committed, this allows for fine tuning of what you commit.

Notes on Ruby in 100 minutes

While on part 4, I discovered that it seems as if double quotes are different than single quotes for string interpolation, meaning that: def make_toast(color)
puts 'du it #{color}'
end

returns du it #{color} no matter what argument is passed to the method. The intended effect from running the method with the argument 'burnt', being du it burnt can only be accomplished with double quotes: def make_toast(color)
puts "du it #{color}"
end

Also, sort of annoyingly, it looks as if each block, whether it be a class, function, or loop, needs to end with end; practical, but annoying if transitioning from python.

At the end of a block of a method in Ruby, some value will automatically always be returned, by default this is the last expression that is evaluated. If we can return the object that we used the method on (with return self), then methods can be done back to back, called method chaining. So for instance, with: