I’m having a hard time learning ruby

For starters, just do you know where I’m coming from: I have little to
no programming experience, except for some C and VB classes I took 6
years ago, which I did fine in.

My biggest hurdle getting started with ruby is finding which
methods/classes/files to call upon for whatever the heck I’m trying to
accomplish.

I’m use to being able to perform a search, like in MSDN Library, using
key words of something I’m trying to perform. Then research results
from there, and get pointed in the right direction (with explanations on
what the feature does, and examples, etc).

The editors also helped with showing the available methods, as I wrote
the code.

So, with ruby, I’m using the SciTE editor (on WinXP), which doesn’t give
method options as you go. Yeah, I know they are kinda like training
wheels, but they help when you’re starting out.

And I can’t really find any close equivalent to using something like an
MSDN Library. The best thing someone has pointed me to so far is
http://www.ruby-doc.org/. Which is cool and all, but it’s not really
“searchable”—you kind of have to know what file/class/method to look up
in the first place. And even if I find what I think I’m looking for,
the documentation is confusing to me. Sometimes there isn’t the
slightest word as to what something does.

Someone told me about “.methods”, but that only works if you’re in an
irb session, which I find painful to use because I have to type all my
code in, line by line. I can’t even figure out how to paste each line
of the code I already have. Inevitably I fat finger something and get
mad.

So, you can kinda see a n00bs frustration….

I must be missing something big. Any tips (other than “try not to suck
so much”)?

= )

···

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

Do you have the Pick-Axe (Programming Ruby from the Pragmatic
Programmers)? If not, I highly recommend you pick that up. And, while
you're at it, pick up the Ruby Recipes, which will have tons of
example code for all kinds of things you might want to do!

M.T.

Just read this: http://www.rubycentral.com/book/

···

---
Ramsey <yesmar@speakeasy.net>
GPG fingerprint = 0E28 4713 428E AC4E AE05 A4A6 D70B 321D 7188 3AD0

On Aug 3, 2006, at 11:05 AM, Nate Imaqaguy wrote:

For starters, just do you know where I’m coming from: I have little to
no programming experience, except for some C and VB classes I took 6
years ago, which I did fine in.

My biggest hurdle getting started with ruby is finding which
methods/classes/files to call upon for whatever the heck I’m trying to
accomplish.

I’m use to being able to perform a search, like in MSDN Library, using
key words of something I’m trying to perform. Then research results
from there, and get pointed in the right direction (with explanations on
what the feature does, and examples, etc).

The editors also helped with showing the available methods, as I wrote
the code.

So, with ruby, I’m using the SciTE editor (on WinXP), which doesn’t give
method options as you go. Yeah, I know they are kinda like training
wheels, but they help when you’re starting out.

And I can’t really find any close equivalent to using something like an
MSDN Library. The best thing someone has pointed me to so far is
http://www.ruby-doc.org/\. Which is cool and all, but it’s not really
“searchable”—you kind of have to know what file/class/method to look up
in the first place. And even if I find what I think I’m looking for,
the documentation is confusing to me. Sometimes there isn’t the
slightest word as to what something does.

Someone told me about “.methods”, but that only works if you’re in an
irb session, which I find painful to use because I have to type all my
code in, line by line. I can’t even figure out how to paste each line
of the code I already have. Inevitably I fat finger something and get
mad.

So, you can kinda see a n00bs frustration….

I must be missing something big. Any tips (other than “try not to suck
so much”)?

= )

--
Posted via http://www.ruby-forum.com/\.

As a newb myself I always find some delight in the realization that
other people are struggling as well. So, in reality I can't address
specifically the parallels you are looking for between past languages
and Ruby.
My suggestion though would be to read up , books, like Programming
Ruby, edition 1 is available online and 2nd edition for sale as a pdf
and / or hard copy. IRB is your friend because it helps you test code
in a very fast way. I do believe one thing - that the time you study
and soak in the material will be returned via Ruby's incredible
pseduo-code like style. There are many methods that will make things
so much easier then most other languages. Maybe I'm just naive and
could even be wrong but after about a month now , is how I see things.

Stuart

···

On 8/3/06, Nate Imaqaguy <breakingsoftware@gmail.com> wrote:

For starters, just do you know where I'm coming from: I have little to
no programming experience, except for some C and VB classes I took 6
years ago, which I did fine in.

My biggest hurdle getting started with ruby is finding which
methods/classes/files to call upon for whatever the heck I'm trying to
accomplish.

I'm use to being able to perform a search, like in MSDN Library, using
key words of something I'm trying to perform. Then research results
from there, and get pointed in the right direction (with explanations on
what the feature does, and examples, etc).

The editors also helped with showing the available methods, as I wrote
the code.

So, with ruby, I'm using the SciTE editor (on WinXP), which doesn't give
method options as you go. Yeah, I know they are kinda like training
wheels, but they help when you're starting out.

And I can't really find any close equivalent to using something like an
MSDN Library. The best thing someone has pointed me to so far is
http://www.ruby-doc.org/\. Which is cool and all, but it's not really
"searchable"—you kind of have to know what file/class/method to look up
in the first place. And even if I find what I think I'm looking for,
the documentation is confusing to me. Sometimes there isn't the
slightest word as to what something does.

Someone told me about ".methods", but that only works if you're in an
irb session, which I find painful to use because I have to type all my
code in, line by line. I can't even figure out how to paste each line
of the code I already have. Inevitably I fat finger something and get
mad.

So, you can kinda see a n00bs frustration….

I must be missing something big. Any tips (other than "try not to suck
so much")?

= )

--
Posted via http://www.ruby-forum.com/\.

My biggest hurdle getting started with ruby is finding which
methods/classes/files to call upon for whatever the heck I’m trying to
accomplish.

I’m use to being able to perform a search, like in MSDN Library, using
key words of something I’m trying to perform. Then research results
from there, and get pointed in the right direction (with explanations on
what the feature does, and examples, etc).

That seems to be a common problem for languages I like: discoverability
sucks (relative to that in languages I don't like, unfortunately). One
tends to end up needing to ask questions of people rather than simply
looking up the answers oneself, much of the time. Somehow, I've managed
anyway.

It mostly sounds like what you need is a good reference, and not so much
an instructional book. I hesitate to say "go spend money" -- it would
be awfully nice if there were a free solution to this problem. I don't
really see such a thing available, though. As such, perhaps you should
look into getting O'Reilly's "Ruby In A Nutshell". The Nutshell series
of books from O'Reilly are designed specifically as references full of
listings of the options available, with brief descriptions, presented in
a non-tutorial, searchable manner. If you get an O'Reilly CD Bookshelf
for subjects of interest, you'll likely end up with a digital copy of
the Nutshell reference for that subject matter, which makes it even more
searchable. I don't even know whether there's a CD Bookshelf for Ruby,
though, unfortunately.

So, with ruby, I’m using the SciTE editor (on WinXP), which doesn’t give
method options as you go. Yeah, I know they are kinda like training
wheels, but they help when you’re starting out.

On the rare occasion when I find myself forced to work with text files
of any sort (source code, notes to self, et cetera) on a Windows
machine, SciTE is definitely my preferred way to do it. It's an
excellent programming, and general purpose, text editor. The fact that
it's not designed by someone who's trying to push a programming language
"product", however, ensures it's not going to be encumbered by language
documentation. The lack of such does have its downside.

I wish I had more useful advice to offer on the subject.

···

On Fri, Aug 04, 2006 at 03:05:41AM +0900, Nate Imaqaguy wrote:

--
CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
"The measure on a man's real character is what he would do
if he knew he would never be found out." - Thomas McCauley

My recommendation is: go to

    http://pragmaticprogrammer.com/titles/ruby/index.html

Order both the print and PDF versions of the Programming Ruby book -- you get a special price if you order both together. The PDF is searchable on your computer in the way that have described.
I find myself searching it several times every day.

Your frustration level and blood pressure should quickly return to normal :slight_smile:

Regards, Morton

For starters, just do you know where I'm coming from: I have little to
no programming experience, except for some C and VB classes I took 6
years ago, which I did fine in.

My biggest hurdle getting started with ruby is finding which
methods/classes/files to call upon for whatever the heck I'm trying to
accomplish.

I'm use to being able to perform a search, like in MSDN Library, using
key words of something I'm trying to perform. Then research results
from there, and get pointed in the right direction (with explanations on
what the feature does, and examples, etc).

I find VS.NET 2003 has a fast and useful help system, but 2005 is way
slow. With Ruby I have a PDF of the Pickaxe book and also bought the
PDF version of Hal Fulton's "The Ruby Way". Using the latest Acrobat
Reader's search features, I get close to the MSDN effect. Beyond that
I use the "Forum Search" - ask a question on Ruby-Talk and normally
within 5 minutes you have 5 answers!

The editors also helped with showing the available methods, as I wrote
the code.

So, with ruby, I'm using the SciTE editor (on WinXP), which doesn't give
method options as you go. Yeah, I know they are kinda like training
wheels, but they help when you're starting out.

I think normal Intellisense would be impossible to do for Ruby because
every variable can be any object at any time. So an editor would have
to run your program to find out what methods a variable supports at a
certain point. That said, Radrails does have limited code completion.

And I can't really find any close equivalent to using something like an
MSDN Library. The best thing someone has pointed me to so far is
http://www.ruby-doc.org/\. Which is cool and all, but it's not really
"searchable"—you kind of have to know what file/class/method to look up
in the first place. And even if I find what I think I'm looking for,
the documentation is confusing to me. Sometimes there isn't the
slightest word as to what something does.

You should buy the PDF versions of a couple of Ruby books and search them.

Someone told me about ".methods", but that only works if you're in an
irb session, which I find painful to use because I have to type all my
code in, line by line. I can't even figure out how to paste each line
of the code I already have. Inevitably I fat finger something and get
mad.

I often start in IRB and then make a mistake and have to do it all in
the editor again. Best to just use an editor. Scite can run your code
quickly - just go to Tools->Go. Radrails can also run your code inside
the IDE.

So, you can kinda see a n00bs frustration….

I must be missing something big. Any tips (other than "try not to suck
so much")?

Keep at it! After a while you'll have a ton of examples of how to do
things, and you just reuse your code. Ruby will pay you back ten times
what you put in. "The Ruby Way" has many many code examples too.

Les

···

On 8/3/06, Nate Imaqaguy <breakingsoftware@gmail.com> wrote:

Nate Imaqaguy wrote:

For starters, just do you know where I’m coming from: I have little to no programming experience, except for some C and VB classes I took 6 years ago, which I did fine in.

My biggest hurdle getting started with ruby is finding which methods/classes/files to call upon for whatever the heck I’m trying to accomplish.

I’m use to being able to perform a search, like in MSDN Library, using key words of something I’m trying to perform. Then research results from there, and get pointed in the right direction (with explanations on what the feature does, and examples, etc).

The editors also helped with showing the available methods, as I wrote the code.

So, with ruby, I’m using the SciTE editor (on WinXP), which doesn’t give method options as you go. Yeah, I know they are kinda like training wheels, but they help when you’re starting out.

And I can’t really find any close equivalent to using something like an MSDN Library. The best thing someone has pointed me to so far is http://www.ruby-doc.org/\. Which is cool and all, but it’s not really “searchable”—you kind of have to know what file/class/method to look up in the first place. And even if I find what I think I’m looking for, the documentation is confusing to me. Sometimes there isn’t the slightest word as to what something does.

Oh man, you have just described my recent experiences to a T. Although it's not searchable, the on-line version of the Programming Ruby "pickaxe" book,
   http://www.rubycentral.com/book
does do a pretty good job of listing just about everything built in on one page:
   http://www.rubycentral.com/book/builtins.html

After reading the paper version of the Pickaxe book, I bought a PDF version (only 10 bucks) of the Pickaxe (see http://www.pragmaticprogrammer.com) and keep it open on my desktop - along with the builtin library page above, and the Ruby-doc.org page you mentioned. I'm still in the hunting and gathering stage of ruby coding, but having those three resources available -- along with Google -- as I'm editing ruby code has been invaluable. In addition there are quite a number of webpages out there containing teaching examples and code snippets.

Oh, and the Ruby Cookbook is a must have too (although it's a hefty beast at 900-odd pages...and it doesn't look like it will be released as a PDF book anytime soon.)

Someone told me about “.methods”, but that only works if you’re in an irb session, which I find painful to use because I have to type all my code in, line by line. I can’t even figure out how to paste each line of the code I already have. Inevitably I fat finger something and get mad.

I hear ya. On my Mac laptop, I haven't figured out how to get command line recall+traverse (up/down,left/right arrows) yet in irb. Drives me nuts. But you can play around within a regular source file rather than use irb directly. Sometimes I just play around at the end of a source file, e.g.

-------- in file fruit.rb ---------
#!/usr/bin/env ruby
class Fruit
   def initialize
     @bananas=0
   end
   def pick
     @bananas += 1
   end
   def eat
     @bananas -= 1
   end
   def howmany?
     @bananas
   end
end

# Muck around test code for above classes follows.....
fruit=Fruit.new
puts "Picking some fruit...."
(1..10).each {|i| fruit.pick}
puts "Eating some fruit...."
fruit.eat
puts "I have #{fruit.howmany?} piece(s) of fruit left."

···

---------------------------------

And then simply do

$ ruby -w fruit.rb

on the command line or, in irb, use "require"

irb(main):001:0> require 'fruit'
Picking some fruit....
Eating some fruit....
I have 9 piece(s) of fruit left.
=> true

to see if the stuff after the "actual" code (e.g. classes, modules, whatnot) does what I think it does. If not, I modify, save, and re-run.

Extremely low-tech .... but I'm having a ball. :o)

cheers,

paulv

--
Paul van Delst Ride lots.
CIMSS @ NOAA/NCEP/EMC Eddy Merckx
Ph: (301)763-8000 x7748
Fax:(301)763-8545

I share your frustration. I have yet to find any really nice, interactive ruby documentation. I think part of the problem is that the core of the language isn't even fully documented. But ruby-doc.org is doing a lot of work to fix this problem.

Contrary to a lot of people on this list, I don't recommend Pickaxe for introduction. It is awesome reference, but I found it really dry as an introductory text. If you have a good sense of humor and some patience, I'd recommend The Poignant Guide http://poignantguide.net/ruby/\.

Then to get some early practice with the ideas, I'd recommend rubyquiz.com. There's a lot of nice little exercises there with lots of source code and analysis for each problem. (Note: download all the solutions, as some of the older individual solutions reference mailing list archives that are no longer available).

Finally, when you're stuck, ask a question here. It's one of the nicest programming lists I've ever been on.
-Mat

···

On Aug 3, 2006, at 2:05 PM, Nate Imaqaguy wrote:

For starters, just do you know where I’m coming from: I have little to
no programming experience, except for some C and VB classes I took 6
years ago, which I did fine in.

My biggest hurdle getting started with ruby is finding which
methods/classes/files to call upon for whatever the heck I’m trying to
accomplish.

I’m use to being able to perform a search, like in MSDN Library, using
key words of something I’m trying to perform. Then research results
from there, and get pointed in the right direction (with explanations on
what the feature does, and examples, etc).

The editors also helped with showing the available methods, as I wrote
the code.

So, with ruby, I’m using the SciTE editor (on WinXP), which doesn’t give
method options as you go. Yeah, I know they are kinda like training
wheels, but they help when you’re starting out.

And I can’t really find any close equivalent to using something like an
MSDN Library. The best thing someone has pointed me to so far is
http://www.ruby-doc.org/\. Which is cool and all, but it’s not really
“searchable”—you kind of have to know what file/class/method to look up
in the first place. And even if I find what I think I’m looking for,
the documentation is confusing to me. Sometimes there isn’t the
slightest word as to what something does.

Someone told me about “.methods”, but that only works if you’re in an
irb session, which I find painful to use because I have to type all my
code in, line by line. I can’t even figure out how to paste each line
of the code I already have. Inevitably I fat finger something and get
mad.

So, you can kinda see a n00bs frustration….

I must be missing something big. Any tips (other than “try not to suck
so much”)?

= )

Don't forget ri!

$ ri Array#each
$ ri Enumerable

etc.

:slight_smile:

Nate Imaqaguy wrote:

···

For starters, just do you know where I'm coming from: I have little to
no programming experience, except for some C and VB classes I took 6
years ago, which I did fine in.

My biggest hurdle getting started with ruby is finding which
methods/classes/files to call upon for whatever the heck I'm trying to
accomplish.

I'm use to being able to perform a search, like in MSDN Library, using
key words of something I'm trying to perform. Then research results
from there, and get pointed in the right direction (with explanations on
what the feature does, and examples, etc).

The editors also helped with showing the available methods, as I wrote
the code.

So, with ruby, I'm using the SciTE editor (on WinXP), which doesn't give
method options as you go. Yeah, I know they are kinda like training
wheels, but they help when you're starting out.

And I can't really find any close equivalent to using something like an
MSDN Library. The best thing someone has pointed me to so far is
http://www.ruby-doc.org/\. Which is cool and all, but it's not really
"searchable"-you kind of have to know what file/class/method to look up
in the first place. And even if I find what I think I'm looking for,
the documentation is confusing to me. Sometimes there isn't the
slightest word as to what something does.

Someone told me about ".methods", but that only works if you're in an
irb session, which I find painful to use because I have to type all my
code in, line by line. I can't even figure out how to paste each line
of the code I already have. Inevitably I fat finger something and get
mad.

So, you can kinda see a n00bs frustration....

I must be missing something big. Any tips (other than "try not to suck
so much")?

= )

--
Posted via http://www.ruby-forum.com/\.

Someone told me about “.methods”, but that only works if you’re in an
irb session, which I find painful to use because I have to type all my
code in, line by line. I can’t even figure out how to paste each line
of the code I already have. Inevitably I fat finger something and get
mad.

On Windows, I've found running irb as:

irb --noreadline

can provide more hassle-free support for line editing / copy / paste and
command history in irb.

Hope this helps,

Bill

···

From: "Nate Imaqaguy" <breakingsoftware@gmail.com>

"Nate Imaqaguy" <breakingsoftware@gmail.com> wrote in message
news:ff1d62f8d0af3f4e5b1e66a085fabec5@ruby-forum.com...

For starters, just do you know where I'm coming from: I have little to
no programming experience, except for some C and VB classes I took 6
years ago, which I did fine in.

    This is, perhaps, your biggest hurdle, in my opinion. As much as I love
Ruby, I've always been suspicious of Ruby as a first language. It's so free
and lacks any kind of hand-holding, which is a breath of fresh air for
experienced programmers but can be a hurdle for novices...

My biggest hurdle getting started with ruby is finding which
methods/classes/files to call upon for whatever the heck I'm trying to
accomplish.

    However, if this is your only problem then you're probably a more
competent programmer than you let on. If that's the case, Paul's suggestion
of this reference will be valuable to you:

http://www.rubycentral.com/book/builtins.html

    It's not exactly searchable but, if you know what kind of behaviour
you're looking for, you can probably simply guess what you're looking for
and be right. For instance, if you're looking for string concatenation,
then you can guess that it will be a method of the "String" class and then,
look at all the methods of that class for something that might suggest
concatenation. You can get quite far doing simply this...

I'm use to being able to perform a search, like in MSDN Library, using
key words of something I'm trying to perform. Then research results
from there, and get pointed in the right direction (with explanations on
what the feature does, and examples, etc).

    I'm an experienced MS Windows developer and I am, thus, intimately
familiar with both the Win32 API and the MSDN Library and, yet, despite all
this, I've never found the search tool (as you've described it) useful, so I
can't help you here.

    I don't know if this is considered rude or not but, since the Pickaxe
book is available online at:

http://www.rubycentral.com/book/

    ...you could simply suck down the entire site and perform your search on
the HTML, all for free. Again, I don't know how the community feels about
you downloading the entire online "book," so my apologies if this is
considered rude...

And I can't really find any close equivalent to using something like an
MSDN Library. The best thing someone has pointed me to so far is
http://www.ruby-doc.org/\. Which is cool and all, but it's not really
"searchable"-you kind of have to know what file/class/method to look up
in the first place. And even if I find what I think I'm looking for,
the documentation is confusing to me. Sometimes there isn't the
slightest word as to what something does.

    Embarrassingly enough, I wasn't aware of ruby-doc.org before and, now
that I'm looking at it, it looks like an excellenet reference, which doesn't
bode well for the advice I have given you up til now. I haven't scrutinized
it but ,judging from the documentation for class "Array," it looks rather
thorough. Are you looking up more obscure functionality?

Someone told me about ".methods", but that only works if you're in an
irb session, which I find painful to use because I have to type all my
code in, line by line. I can't even figure out how to paste each line
of the code I already have. Inevitably I fat finger something and get
mad.

    The "methods" method works anywhere in Ruby but it is most useful in an
IRB session.
    I'm unsure why you want to type in your entire program into IRB. You
probably just want to type in relevant situations to test Ruby's behaviour,
such as operator precedence or regex behaviour.
    If you want to look at all the methods of a class, you simply need to
create an object of said class and call the "methods" method, perahps
followed by the "sort" method which can help you find what you're lookig
for...

So, you can kinda see a n00bs frustration..

I must be missing something big. Any tips (other than "try not to suck
so much")?

    I assure you, we're all familiar with frustration, even if it's not over
the same things.
    Good luck to you and I hope you make progress!

Nate Imaqaguy wrote:

Someone told me about “.methods”, but that only works if you’re in an irb session, which I find painful to use because I have to type all my code in, line by line. I can’t even figure out how to paste each line of the code I already have. Inevitably I fat finger something and get mad.

Here's what I do frequently: enter the text in the editor and then paste it to the IRB session (on Windows you can do that with right mouse click - maybe you have to change settings of the terminal to "quick edit mode" and "insert mode").

Kind regards

  robert

Cool; thanks for all the feedback--excellent info.

I especially like the idea of searching the digital books to get the
MSDN effect. I hadn't thought about that.

-nate

···

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

hope some of these help

Documentation

http://ruby.cenophobie.com/rubycheat.php
The ruby cheat sheet - should go through this one

the ruby quick ref

http://en.wikibooks.org/wiki/Programming:Ruby
wiki book if that helps

http://www.artima.com//rubycs/articles/patterns_sexp_dsls.html
stuff you might want to read latter on...

If you are going to code really seriously might want some theoretical stuff
about general coding:
http://mitpress.mit.edu/sicp/full-text/book/book.html

The links say it all

http://www.techtoolblog.com/archives/195-free-online-programming-books

Hope that helps

Harish

···

On 8/4/06, Seth Thomas Rasmussen <sethrasmussen@gmail.com> wrote:

Don't forget ri!

$ ri Array#each
$ ri Enumerable

etc.

:slight_smile:

Nate Imaqaguy wrote:
> For starters, just do you know where I'm coming from: I have little to
> no programming experience, except for some C and VB classes I took 6
> years ago, which I did fine in.
>
> My biggest hurdle getting started with ruby is finding which
> methods/classes/files to call upon for whatever the heck I'm trying to
> accomplish.
>
> I'm use to being able to perform a search, like in MSDN Library, using
> key words of something I'm trying to perform. Then research results
> from there, and get pointed in the right direction (with explanations on
> what the feature does, and examples, etc).
>
> The editors also helped with showing the available methods, as I wrote
> the code.
>
> So, with ruby, I'm using the SciTE editor (on WinXP), which doesn't give
> method options as you go. Yeah, I know they are kinda like training
> wheels, but they help when you're starting out.
>
> And I can't really find any close equivalent to using something like an
> MSDN Library. The best thing someone has pointed me to so far is
> http://www.ruby-doc.org/\. Which is cool and all, but it's not really
> "searchable"-you kind of have to know what file/class/method to look up
> in the first place. And even if I find what I think I'm looking for,
> the documentation is confusing to me. Sometimes there isn't the
> slightest word as to what something does.
>
> Someone told me about ".methods", but that only works if you're in an
> irb session, which I find painful to use because I have to type all my
> code in, line by line. I can't even figure out how to paste each line
> of the code I already have. Inevitably I fat finger something and get
> mad.
>
> So, you can kinda see a n00bs frustration....
>
> I must be missing something big. Any tips (other than "try not to suck
> so much")?
>
> = )
>
> --
> Posted via http://www.ruby-forum.com/\.

Mat Schaffer wrote:

I share your frustration. I have yet to find any really nice, interactive ruby documentation. I think part of the problem is that the core of the language isn't even fully documented. But ruby- doc.org is doing a lot of work to fix this problem.

I'm always glad to hear when someone finds the site helpful. But I do want to make clear that the actual documentation comes from a relatively small number of very smart, very dedicated Rubyists who volunteer to add and correct the documentation.

Contrary to a lot of people on this list, I don't recommend Pickaxe for introduction. It is awesome reference, but I found it really dry as an introductory text. If you have a good sense of humor and some patience, I'd recommend The Poignant Guide http://poignantguide.net/ ruby/.

I'd highly recommend David A. Black's Ruby for Rails. Doesn't matter if you know or use Rails; you can look at the references to Rails as just an example application used to illustrate essential Ruby language features. (Of course, if you do use Rails then the book is perhaps even more useful.)

···

--
James Britt

"The greatest obstacle to discovery is not ignorance, but the illusion of knowledge."
  - D. Boorstin

But, really, with all of this frustration... it's better than the
frustrations just about anything else will give you... :slight_smile:

M.T.

Seth Thomas Rasmussen wrote:

Don't forget ri!

$ ri Array#each
$ ri Enumerable

BTW, do other folks get this i_formatter.rb warning when they use ri:

lnx:local/ruby-1.8.4 : ri Array#each
/usr/local/lib/ruby/1.8/rdoc/ri/ri_formatter.rb:46: warning: (...) interpreted as grouped expression

....followed by the actual rdoc output....

?? I get it on linux and mac osx

cheers,

paulv

···

--
Paul van Delst Ride lots.
CIMSS @ NOAA/NCEP/EMC Eddy Merckx
Ph: (301)763-8000 x7748
Fax:(301)763-8545

Nate Imaqaguy wrote:

For starters, just do you know where I’m coming from: I have little to no programming experience, except for some C and VB classes I took 6 years ago, which I did fine in.
My biggest hurdle getting started with ruby is finding which methods/classes/files to call upon for whatever the heck I’m trying to accomplish.

Well, I had years of experience in lots of languages when I started into Ruby, but my experience definitely did NOT include Java or C, which is taken for granted in a lot of documentation. "This works a lot like a C zingwanger, except you can modify it while it's running," and the like. Sigh.

Playing the guessing game of "if I were a command to do X, what would I call myself?" is something I still get to do a lot of. "Collect" and "index," (I'd never have guessed 'index' was a search function!) for arrays, and figuring out which of "chomp/chop/slice/split/strip" methods for strings I might want, were all non-obvious solutions to various problems I had when programming.

I’m use to being able to perform a search, like in MSDN Library, using key words of something I’m trying to perform.

There are two factors that get in the way of being able to ask "How do I do ____?"

One, Ruby's documentation, like Ruby, is still really young compared to the languages you're used to (even if you subtract six years!).

Two, the basic commands in Ruby (I think) are often dramatically more powerful than the core commands of other languages. For example, every 4-6 weeks, somebody pops up asking where on earth they can find a shuffle command. The answer is the deliciously clever, but obvious only in retrospect myarray.sort_by{rand}. Ruby has armloads of cases where the way you do _____ is by combining some of the basic, powerful operators; which is why they tend not to cause people to easily say "here's what this command is for;" it's good for too many things to easily list.

I think the new "Ruby Cookbook" is intended to help with that problem. :slight_smile:

The other thing I'd suggest is carefully studying some of the really key methods. There's usually seven ways to do anything in Ruby. Here are the methods that I personally have found myself using over and over again:

Arrays

···

On Aug 3, 2006, at 12:55, Paul van Delst wrote:
  +
  <<
   # you'd think you'd know this, but there's ranges: myArray[4..7]
        negative numbers: myArray[1..-1]
        and what happens when you type anArray[2].
  assoc # an array-of-arrays search system
  collect
  collect!
  each
  flatten
  index
  join # especially the .join('') form...
  sort

Some of the other commands are just synonyms for these (use whichever you prefer), and others I just haven't used as much. Also, some of those commands are actually part of Enumerable. Parts of Enumerable worth getting to know include

Enumerable
  collect #this one's crazy powerful voodoo
  each_with_index
  find (aka detect)
  find_all
  grep
  inject #this one's more crazy powerful voodoo
  sort_by

String
  +
  =~ # I find myself using regular expressions a lot; I wish they weren't so confusing.
  chomp
  each # especially each('')
  gsub # and sub, sub!, and gsub!
  match
  scan # and trying to figure out when I want .match and when .scan, often with {}
  split
  succ # this one's really strange

That's it. That's the stuff I seem to keep using over and over. For fiddling with files, I'd suggest skipping the annoying File, Dir, and IO stuff and going straight to Pathname. Thankfully, the number-related methods are mostly pretty normal, and usually named as you'd expect.

I hear ya. On my Mac laptop, I haven't figured out how to get command line recall+traverse (up/down,left/right arrows) yet in irb. Drives me nuts. But you can play around within a regular source file rather than use irb directly. Sometimes I just play around at the end of a source file, e.g.

That requires the "readline" library for some reason. (The regular command line does this, but irb apparently can't tap that resource or something. <shrug>) It took me three tries and a couple hours to get readline located, downloaded, installed, and enabled. (First I had to download and install some new installer program. Fink, DarwinPorts, I don't remember. Blah.) But I seem to have abysmal luck with anybody's installer besides the native OSX one.

And then simply do

$ ruby -w fruit.rb

on the command line or, in irb, use "require"

irb(main):001:0> require 'fruit'
Picking some fruit....
Eating some fruit....
I have 9 piece(s) of fruit left.
=> true

to see if the stuff after the "actual" code (e.g. classes, modules, whatnot) does what I think it does. If not, I modify, save, and re-run.

Hmm. I usually use 'load' instead of 'require' when I'm doing that sort of experiment. "Require" will try to not load the same file more than once, and I tend to leave irb up and running, so 'load' will replace what's in irb's memory with the new whatever that's in my file. But I've also definitely replaced bits of things. "Hmm, this one function doesn't work." {rewrite rewrite}

  > class SomeClass
  >
    copy and paste one function out of the middle of the whole class
  > end

Presto. One method from the middle of the class changed, with whatever data I'd already gotten loaded in, still intact. It's kind of freaky.

[ snip ]

I share your frustration. I have yet to find any really nice,
interactive ruby documentation. I think part of the problem is that
the core of the language isn't even fully documented. But ruby-
doc.org is doing a lot of work to fix this problem.

Contrary to a lot of people on this list, I don't recommend Pickaxe
for introduction. It is awesome reference, but I found it really dry
as an introductory text. If you have a good sense of humor and some
patience, I'd recommend The Poignant Guide http://poignantguide.net/
ruby/.

Then to get some early practice with the ideas, I'd recommend
rubyquiz.com. There's a lot of nice little exercises there with lots
of source code and analysis for each problem. (Note: download all
the solutions, as some of the older individual solutions reference
mailing list archives that are no longer available).

Finally, when you're stuck, ask a question here. It's one of the
nicest programming lists I've ever been on.
-Mat

Have any of you tried why's "Try Ruby" ?

http://tryruby.hobix.com/

- rob

···

On 8/3/06, Mat Schaffer <schapht@gmail.com> wrote:

--