[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

most useful instance methods

Adam Akhtar

2/12/2008 11:07:00 PM

Ive just been getting to grips with some of the string and array
methods. The basics were easy enough such as reverse. Then came map and
uniq. Im wondering what else is good to practice with. It seems to make
sense to study new methods on the basis of their useage. So what methods
do you constantly use or couldnt live without for arrays and strings
without including the elementary stuff like push pop etc.

Perhaps you think there arent that many methods but to a beginner like
me every time i open the pickaxe to look at what method could help solve
a problem I soon feel lost amongst them.
--
Posted via http://www.ruby-....

5 Answers

Trans

2/13/2008 12:20:00 AM

0



On Feb 12, 6:07 pm, Adam Akhtar <adamtempor...@gmail.com> wrote:
> Ive just been getting to grips with some of the string and array
> methods. The basics were easy enough such as reverse. Then came map and
> uniq. Im wondering what else is good to practice with. It seems to make
> sense to study new methods on the basis of their useage. So what methods
> do you constantly use or couldnt live without for arrays and strings
> without including the elementary stuff like push pop etc.
>
> Perhaps you think there arent that many methods but to a beginner like
> me every time i open the pickaxe to look at what method could help solve
> a problem I soon feel lost amongst them.

I suggest reading though the whole reference section, at least enough
to get a quick imprint of every core method. Start with Kernel/Object
though.

T.

Thomas Wieczorek

2/13/2008 6:19:00 AM

0

On Wed, Feb 13, 2008 at 12:07 AM, Adam Akhtar <adamtemporary@gmail.com> wrote:
> Ive just been getting to grips with some of the string and array
> methods. The basics were easy enough such as reverse. Then came map and
> uniq. Im wondering what else is good to practice with. It seems to make
> sense to study new methods on the basis of their useage. So what methods
> do you constantly use or couldnt live without for arrays and strings
> without including the elementary stuff like push pop etc.
>

inject, *, +, -, sort(with and without block), compact and join from the Array.

James Britt

2/13/2008 7:52:00 AM

0

Trans wrote:
>
> On Feb 12, 6:07 pm, Adam Akhtar <adamtempor...@gmail.com> wrote:
>> Ive just been getting to grips with some of the string and array
>> methods. The basics were easy enough such as reverse. Then came map and
>> uniq. Im wondering what else is good to practice with. It seems to make
>> sense to study new methods on the basis of their useage. So what methods
>> do you constantly use or couldnt live without for arrays and strings
>> without including the elementary stuff like push pop etc.
>>
>> Perhaps you think there arent that many methods but to a beginner like
>> me every time i open the pickaxe to look at what method could help solve
>> a problem I soon feel lost amongst them.
>
> I suggest reading though the whole reference section, at least enough
> to get a quick imprint of every core method. Start with Kernel/Object
> though.

Good plan.


The problem with trying to pick the "most used" is that it becomes
self-fulfilling. Most people will tend to use the methods that are most
familiar, which makes them *more* familiar, which makes them more often
used. And so on.

Here's a small hacking project:

Write a ruby app that grabs a random API page from ruby-doc.org and
brings it up in a browser.

Run it a few times each day and scan over what you see.

After a while, as you code, you'll start recalling various methods that
seem just right for various tasks, and your Ruby vocabulary and
experience will expand.


--
James Britt

www.risingtidesoftware.com - Wicked Cool Coding
www.rubystuff.com - The Ruby Store for Ruby Stuff

Thomas Wieczorek

2/13/2008 1:47:00 PM

0

On Wed, Feb 13, 2008 at 8:52 AM, James Britt <james.britt@gmail.com> wrote:
>
>
> Write a ruby app that grabs a random API page from ruby-doc.org and
> brings it up in a browser.
>

What a great idea! I just wrote it. Thank you!

For those interested: It uses the Windows start command to open a site
from the Ruby 1.8.6 Core rubydoc list.

require 'open-uri'
require 'hpricot'

base = "http://ruby-doc.org/c...
topic_site = Hpricot(open(base + "fr_class_index.html"))
list = topic_site.search("//div[@id='index-entries']/a[@href]")
system("start " + base + list[rand(list.length)].attributes['href'])

Adam Akhtar

2/13/2008 10:48:00 PM

0

yeah sounds like a cool learning project as well. Ive deliberately
avoided looking at the above code and will give this a shot. Thanks as
well for the method recs!


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