I want to add a method to be run on Strings. Currently, I’m just adding
it on to the String class. Should I be subclassing it instead? Creating
a method which takes a String as an argument?
Leif K-Brooks wrote:
I want to add a method to be run on Strings. Currently, I’m just adding
it on to the String class. Should I be subclassing it instead? Creating
a method which takes a String as an argument?
I have mixed feelings about re-opening built-in classes (like String) to
add new methods to them, even though the provision for this is one of
Ruby’s attractions. My concern is that people get used to the built-ins
and expect certain standard behaviors from them; augmenting or otherwise
changing them could create confusion for other people looking at your code.
I don’t think there’s a “right” answer to the question. If I were in
your situation I’d probably write a little helper method that takes the
string as an input argument.
Jusy my $0.02,
Lyle
I’m looking for a very indepth book on Ruby. Any suggestions?
Zach
Lyle Johnson wrote:
Leif K-Brooks wrote:
I want to add a method to be run on Strings. Currently, I’m just
adding it on to the String class. Should I be subclassing it instead?
Creating a method which takes a String as an argument?I have mixed feelings about re-opening built-in classes (like String) to
add new methods to them, even though the provision for this is one of
Ruby’s attractions. My concern is that people get used to the built-ins
and expect certain standard behaviors from them; augmenting or otherwise
changing them could create confusion for other people looking at your code.
I think one way this has been done very effectively is the “Time” class.
The standard one contains a certain set of commands, but if you want more,
you simply “require ‘time’” and it now has a bunch more methods, like
“iso8601”.
The other way this has been done very well is with ‘yaml’. If you require
this module, everything gains a “to_yaml” method. The name makes it
clear that you shouldn’t expect that method to appear without ‘yaml’.
As long as you’re not changing the behaviour of any built-in methods, and
you make it clear the methods aren’t “native”, you should be ok.
Ben
“Zach Dennis” zdennis@mktec.com wrote in message
I’m looking for a very indepth book on Ruby. Any suggestions?
Depends on how “in depth” you want !
There are only 6 books on Ruby in English, so you may have to learn Japanese
to learn aout Ruby Internals.
Zach
– shanko
256 Books [ what’s that ? ]
http://www.andsoforth.com/galleries/seattle2002/tn/dcp_0682.jpg.html
The Ruby Developer’s Book is also a good cookbook
Zach Dennis wrote:
···
I’m looking for a very indepth book on Ruby. Any suggestions?
Zach
Depends on how “in depth” you want !
I read the Programming Ruby: Pragmatic Guide and I liked it very much for my
first Ruby book. It got me accustomed to the language. However I don’t want
my nextRuby book to be one of those books where I can skip the first 100 to
150 pages because it goes over how a for loop works etc…The other Ruby
books out there may not even do this, but I have some books for other
languages where I only get something useful out of the last few chapters.
There are only 6 books on Ruby in English, so you may have to learn
Japanese
to learn aout Ruby Internals.
Isn’t Japanese one of thee hardest languages to learn? Maybe I could just
look at the source code examples. =)
Zach
Ok this picture was depressing and makes me want to cry. Why do they only
offer French, German or Spanish in the public school systems in the U.S. for
a choice of foreign langauges? I’m being hindered to learn by my inadequate
public schooling.
“I think I’m Japanese, I think I’m Japanese, I really think so…” One can
wish.
sigh
Zach
···
-----Original Message-----
From: Bermejo, Rodrigo [mailto:rodrigo.bermejo@ps.ge.com]
Sent: Wednesday, December 03, 2003 6:51 PM
To: ruby-talk ML
Subject: Re: Indepth Ruby Book
256 Books [ what’s that ? ]
http://www.andsoforth.com/galleries/seattle2002/tn/dcp_0682.jpg.html
The Ruby Developer’s Book is also a good cookbook
Zach Dennis wrote:
I’m looking for a very indepth book on Ruby. Any suggestions?
Zach
“Zach Dennis” zdennis@mktec.com wrote in message
However I don’t want
my nextRuby book to be one of those books where I can skip the first 100
to
150 pages because it goes over how a for loop works etc…
Take a look at “The Ruby Way”.
Isn’t Japanese one of thee hardest languages to learn? Maybe I could just
look at the source code examples. =)
Agree ! Let us all contribute to pay for translations in English
···
Zach
“The Ruby Way” is an excellent book.
I think complements very well the “Programming Ruby: Pragmatic Guide”
AND is well written.
You are going to find there a few things you already know,
but always seen from a interesting perspective.
Mauro
···
On Wed, 3 Dec 2003 13:03:42 +0900 “Zach Dennis” zdennis@mktec.com wrote:
Depends on how “in depth” you want !
I read the Programming Ruby: Pragmatic Guide and I liked it very much for my
first Ruby book. It got me accustomed to the language. However I don’t want
my nextRuby book to be one of those books where I can skip the first 100 to
150 pages because it goes over how a for loop works etc…The other Ruby
books out there may not even do this, but I have some books for other
languages where I only get something useful out of the last few chapters.There are only 6 books on Ruby in English, so you may have to learn
Japanese
to learn aout Ruby Internals.Isn’t Japanese one of thee hardest languages to learn? Maybe I could just
look at the source code examples. =)Zach
“Zach Dennis” zdennis@mktec.com wrote in message news:NCEFIOKHDAJMKDIGMJJKEEGACGAA.zdennis@mktec.com…
Ok this picture was depressing and makes me want to cry. Why do they only
offer French, German or Spanish in the public school systems in the U.S. for
a choice of foreign langauges? I’m being hindered to learn by my inadequate
public schooling.
What we need no is someone to translate these into English.
I agree that we need more people learning languages other
that European in school.
When I was a grad student, they reduced foreign lang. requirements for
PhD from 2 langs to 1 (I took French).
I think they were talking about programming as counting as a lang
or some such nonsense.
Do they do that now? (count programming as a foreign lang?)
Van
“Zach Dennis” zdennis@mktec.com writes:
Ok this picture was depressing and makes me want to cry. Why do they only
offer French, German or Spanish in the public school systems in the U.S. for
a choice of foreign langauges? I’m being hindered to learn by my inadequate
public schooling.
At least when I went to high school, if you wanted to take a class
that wasn’t offered at the high school, but was at the local
university, the school district would pay for you to take it there.
Of course, this requires that you have a local university, but hey.
-=Eric
···
–
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
– Blair Houghton.
When I was a grad student, they reduced foreign lang. requirements for
PhD from 2 langs to 1 (I took French).
I think they were talking about programming as counting as a lang
or some such nonsense.Do they do that now? (count programming as a foreign lang?)
Yes, but only if its perl.
···
In message 70ae81fd.0312060006.3be76384@posting.google.com, Van Jacques vanjac12@yahoo.com writes
Van
–
Ian - posting to a Newsgroup. Please remove everything to reply.
Good info, however for me it’s 3 years to late and the town I lived in
didn’t have a local university anywhere near it. =)
Zach
···
-----Original Message-----
From: Eric Schwartz [mailto:emschwar@pobox.com]
Sent: Tuesday, December 09, 2003 3:47 PM
To: ruby-talk ML
Subject: Re: Indepth Ruby Book
“Zach Dennis” zdennis@mktec.com writes:
Ok this picture was depressing and makes me want to cry. Why do they only
offer French, German or Spanish in the public school systems in the U.S.
for
a choice of foreign langauges? I’m being hindered to learn by my
inadequate
public schooling.
At least when I went to high school, if you wanted to take a class
that wasn’t offered at the high school, but was at the local
university, the school district would pay for you to take it there.
Of course, this requires that you have a local university, but hey.
-=Eric
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
– Blair Houghton.