[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Puzzling behaviour with range...

Andy Cooper

1/7/2009 5:13:00 PM

> Sebastian Hungerecker wrote:
> >
> > a) Range is not a numeric
> > b) Which difference do you mean?
> >=20
> > HTH,
> > Sebastian
>=20
> Thanks for the reply!
>=20
> Of course, in typing this out, I see why it's set up the way it is,=20
> since we might want to do something like this...
>=20
> class SomeObj
> def lastOne()
> 17
> end
> end
> blah =3D SomeObj::new
> a =3D 1..blah.lastOne
>=20
> Thanks for setting me on the path! (and letting me babble on...)


Well it all comes down to the principle of least surprise in the end,
and I think that it is properly set up to fit within the principle. Even
though none of us wants to put parenthesis ... anywere really.

Andy Cooper.

1 Answer

Dave Bass

1/8/2009 11:30:00 AM

0

Andy Cooper wrote:
> Even
> though none of us wants to put parenthesis ... anywere really.

Well, at least one of us likes parentheses.

If you see something like (3.14).class you don't have to stop and think
about it. But 3.14.class makes one mentally come to a screeching halt,
back up, do a double-take, and then get out the Pickaxe book to look up
the precedence rules. Or fire up irb and suck-it-and-see. ;-)

I prefer clarity over saving a couple of keystrokes!

Dave
--
Posted via http://www.ruby-....