From: "David A. Black" Date: 2008-04-23T20:02:01+09:00 Subject: Re: Ruby and object paradigm --1926193751-1299194734-1208948520=:32526 Content-Type: MULTIPART/MIXED; BOUNDARY="1926193751-1299194734-1208948520=:32526" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --1926193751-1299194734-1208948520=:32526 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Hi -- On Wed, 23 Apr 2008, Pe=F1a, Botp wrote: > From: Andres [mailto:andresgaragiola@gmail.com] > # I=B4m a smalltalk developer and now i'm beginning with Ruby. I found > > smalltalk is cool. > > # words like "puts" on the ruby syntax that i don=B4t understand. > > rtfm ;) > > # The basic object paradigm formula is "receiver + message", an emisor > # send a message to a receiver. > > yes. but ruby is nice. it does not "forces" us to do things just because= of some oo paradigm.. remember, not everyone view the programming world as= receiver.message only; eg, i feel at ease writing 1+1 instead of 1.+ 1 ;) > > > # is > # Transcript show: 'Hello world' > > if you want a longer way, no problem. > > 070:0> Kernel.puts "hello" > hello > =3D> nil > > note, other objects may implem puts too, but you already know that ;) > > # factorial > # ^self =3D 0 ifTrue: [ 1 ] ifFalse: [ self * ((self-1) factorial) ] > > another way in ruby > > 059:1> def factorial > 060:2> self=3D=3D0 ? 1 : self * (self-1).factorial > 061:2> end > =3D> nil > > > # the message #ifTrue:ifFalse: is implemented in the class Boolean and > # in his subclasses, and receive two block argmuments, the behavior if > # the boolean is true and the behavior if the boolean is false. I don=B4t > # understand like it works in ruby, when is implemented the message "if > # else"? > > 1 current ruby does not support multiple blocks as arguments I would say that Ruby doesn't support multiple blocks as blocks, but it does support multiple Proc objects as arguments, if you want to go that route. David --=20 Rails training from David A. Black and Ruby Power and Light: INTRO TO RAILS June 9-12 Berlin ADVANCING WITH RAILS June 16-19 Berlin INTRO TO RAILS June 24-27 London (Skills Matter) See http://www.rubypal.com for details and updates! --1926193751-1299194734-1208948520=:32526-- --1926193751-1299194734-1208948520=:32526--