Day 14 – Blocks, Procs, and the Others
I get it. Seven pages into Day 14 trying to figure out what other
meant in Slagell’s examples and it clicks.
In other languages I’m familiar with (Applescript, PHP, Perl, REALbasic) variables are passed through methods. Example if we have a method that’s friendly,
function SayHiTo($name) {
print "Hi, " . $name;
}
and we tell it our name, SayHiTo("Garrick");
The resulting would be Hi, Garrick
.
Fairly straight forward. In Ruby-land, not only can we pass whole objects (or close enough) we can also access the methods within those objects.
Slagell’s other
is this object. Pretty cool. Pretty useful.
I say this hesitantly, Ruby is the programming language I’ve always wanted.
In other languages, when it’s difficult to do something (pass an object through a method) it’s usually because it’s a BadThingToDo. At this point, I’m a bit skeptical of Ruby’s simplicity and ease.
The Macintosh made bad graphic design real easy, the web made bad publishing real easy. REALbasic made bad programming real easy. Does Ruby do the same or is there something in Ruby preventing this?
I sure hope for the latter.
This post documents my journey through Sam’s Teach Yourself Ruby in 21 days. I’ll be joining Al Abut in his effort to learn Ruby and blog along the way.