On Wednesday 28 December 2005 11:37 am, James Edward Gray II wrote:
> On Dec 28, 2005, at 10:13 AM, Steve Litt wrote:
> > Have em start with HelloWorld, then a loop...
>
> Hmm, that's a tricky one to me.  You really need to nail iterators
> ASAP to become a Rubyist.  If you post code here with a loop, odds
> are good we'll start "correcting" it.

That's precisely my point. I'm advocating some "corretion". If you start a 
non-motivated learner with iterators, he'll bail. The long term goal is to  
turn him into a Rubyist, but the immediate goal is to have him accept Ruby 
enough to learn a couple more things.

>
> Also Ruby has no loop equivalent to the famous for(...; ...; ...)
> { ... } construct from most other languages.

for ss in 1...10
	print ss, " Hello\n";
end

ss = 4 
while ss > 0
	puts ss
	ss -= 1
end

The preceding are constructs they've seen in every language. Armed with these 
two loops, it is now a perfect time to introduce object.each(){}, introducing 
both iterators and blocks. Now show him how much more can be done with 
object.each(){}. IMHO the important thing is to move from the known to the 
unknown.

>
> > Show them how much easier inheritance is in Ruby than in C++.
>
> "Favor composition over inheritance."  I think that's even more true
> in Ruby where inheriting the core classes sometimes has surprising
> side effects.

OK, show em how easy composition is, and how well it can be encapsulated. 
attr_accessor rules.

SteveT

Steve Litt
http://www.troubleshooters.com
slitt / troubleshooters.com