|
The Elf With a Pet Ham
Finally! Someone got to writing technical documentation that does not need to be broken up with porn and pictures of beetles to make it fun to read. I'm learning Ruby - on Rails - and compared to the usual slew of boring white books, this is just plain awesome: Why's (poignant) Guide to Ruby (with cartoon foxes). An excerpt:
Animal Perfect is now the future of animal enhancement. They build new animals and salvage old-style animals for parts. Of course, they’ve come a long ways. When Animal Perfect started, you’d see a full-grown bear walk into Animal Perfect and you’d see a full-grown bear with sunglasses walk out. Completely cheesy.
Stick around and you’ll see a crab with his own jet pack. That’s a new 2004 model jetcrab.
But now, the whole operation is up and running. And the cleanliness of the place is astonishing. All the equipment is so shiny. Everything is in chrome. Oh, and all the staff have concealed weapons. They’re trained to kill anyone who enters unannounced. Or, if they run out of bullets, they’re trained to pistol whip anyone who enters unannounced.
'Elf, make me a starmonkey.'First, the star is caught.

Some imaginary Ruby for you:
pipe.catch_a_star
Variable pipe. Method catch_a_star. A lot of Rubyists like to think of methods as a message. Whatever comes before the dot is handed the message. The above code tells the pipe to catch_a_star.
This is the second half of Ruby. Putting things in motion. These things you define and create in the first half start to act in the second half.
1. Defining things.
2. Putting those things into action.
So what if the star catching code works? Where does the star go?
captive_star = pipe.catch_a_star
See, it’s up to you to collect the miserable, little star. If you don’t, it’ll simply vanish. Whenever you use a method, you’ll always be given something back. You can ignore it or use it.
If you can learn to use the answers that methods give you back, then you will dominate.

Quickly then.
starmonkey = ratchet.attach( captive_monkey, captive_star )
The ratchet gets an attach message. What needs to be attached? The method arguments: the captive_monkey and the captive_star. We are given back a starmonkey, which we have decided to hang on to.
This is turning out to be such a short, little proggie that I’m just going to put it all together as one statement.
starmonkey = ratchet.attach( captive_monkey, pipe.catch_a_star ) + deco_hand_frog
See how pipe.catch_a_star is right in the arguments for the method? The caught star will get passed right to the ratchet. No need to find a place to put it. Just let it go.
Link: Why's (poignant) Guide to Ruby (with cartoon foxes) it's Creative Commons Licenced :-)
Also: AJAX on rails
Created 2007-01-30 15:40:28 by 357 and filed under stuffComments 
 |
|
lzlucdb writes...
xWw1Sf auswahhuvevc, [url=http://hftlgfbhmbss.com/]hftlgfbhmbss[/url], [link=http://tdjxadmbggns.com/]tdjxadmbggns[/link], http://wofmlcyhionw.com/ posted: 2011-03-9 21:29:37 |
Add Comment
Subscribe to this blog by RSS.
|
|
|
|