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.
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.
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.
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.
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!
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.