New to Ruby and Programming

Hi,

 I am making yet another attempt at learning to program.  I have a 

little experience with QBASIC, RealBASIC, and Actionscript, but I am
pretty much a novice.

I am working my way through Chris P.'s tutorial but I’m stuck on Procs
and Blocks. I’m just not getting the last half of the chapter.

http://pine.fm/LearnToProgram/

Any guidance or detail explanation would be appreciated

On Aug 15, 2006, at 7:06 PM, Heath Fashina wrote:

Learn to Program, by Chris Pine

Any guidance or detail explanation would be appreciated

I wrote a blog post on this subject a while back that might at least
give you another point of view:

http://blog.grayproductions.net/articles/2006/01/05/code-as-a-data-type

Hope it helps.

James Edward G. II

James G. wrote:

On Aug 15, 2006, at 7:06 PM, Heath Fashina wrote:

Learn to Program, by Chris Pine

Any guidance or detail explanation would be appreciated

I wrote a blog post on this subject a while back that might at least
give you another point of view:

http://blog.grayproductions.net/articles/2006/01/05/code-as-a-data-type

Hope it helps.

James Edward G. II

I have very limited knowledge with databases (i.e. filemaker pro and
some Access). I decided to just press on with my loose grasp of procs
and blocks and dive into:

"Programming Ruby:The Pragmatic Programmer’s Guide, First Edition (*)

Hopefully, it’ll just hit me or I’ll have to find a new hobby

Hey Thanks,

I will definately check that out!

“He Fa” [email protected] wrote in message
news:[email protected]

James G. wrote:
I decided to just press on with my loose grasp of procs
and blocks and dive into:

"Programming Ruby:The Pragmatic Programmer’s Guide, First Edition (*)

Hopefully, it’ll just hit me or I’ll have to find a new hobby

I suspect you may be getting a bit too obsessive about those darn’
blocks
and procs. While blocks can be useful for all kinds of things, they are
not
‘central’ to programming in Ruby. Some Ruby programmers tend to get a
bit
obsessive about blocks, procs, lambda functions and the like. If you
find
this stuff baffling (and unless you already have experience of a
language
such as Smalltalk or Scheme in which blocks are a ‘natural’ part of the
language), they may initially seem very baffling indeed, my advice would
be
to use blocks only where they are absolutely required - namely, for
iterating over collections of things as when, for example, iterating
over
the items in an array using the each() method.

I wouldn’t worry at all about using blocks as ‘nameless functions’ or
passing and ‘yielding’ them. These can be useful in certain
circumstances
but then again, you could spend a lifetime doing perfectly productive
programming in Ruby without ever doing any of those things :wink:

You may perhaps find my book, The Little Book Of Ruby, of some help.
This is
a free PDF book which you can download from: www.sapphiresteel.com

While my book covers most of the essentials of Ruby - including things
that
often stump newcomers (blocks, mixins etc.) I’ve tried to keep restrict
it
to the essential details; you can also download all the source code for
all
the sample programs (personally, it’s my feeling that programming topics
are
often easier to understand when you can try them out for yourself).

best wishes
Huw C.

http://www.sapphiresteel.com
Ruby P.ming In Visual Studio 2005

On 8/16/06, Huw C. [email protected] wrote:

the items in an array using the each() method.

Ruby’s standard library is filled with methods that (often optionally)
take blocks as arguments. Ignoring them isn’t gonna do you any good. A
closure is a function that remembers the environment it was defined
in, and if you don’t understand the concept of a function, programming
is not for you.

I wouldn’t worry at all about using blocks as ‘nameless functions’ or
passing and ‘yielding’ them. These can be useful in certain circumstances
but then again, you could spend a lifetime doing perfectly productive
programming in Ruby without ever doing any of those things :wink:

Ignoring closures, which are extensively used within Ruby’s standard
library and a large part in what makes the language so good for many
tasks, is not going to do you any good at all.

Simen E. wrote:

Hopefully, it’ll just hit me or I’ll have to find a new hobby
this stuff baffling (and unless you already have experience of a
Ruby’s standard library is filled with methods that (often optionally)

Ignoring closures, which are extensively used within Ruby’s standard
library and a large part in what makes the language so good for many
tasks, is not going to do you any good at all.

Perhaps not, but it’s like that advice they give for taking tests…if
you find yourself getting hung up on a particular question, skip it and
come back to it later.
Except, you have much more time to skip blocks/closures for now and come
back to them later than problems on a test.
If it doesn’t make sense now, get familiar with other parts of Ruby and
then come back to blocks, if it’s getting frustrating.

-Justin

“Simen E.” [email protected] wrote in message
news:[email protected]

if you don’t understand the concept of a function, programming
is not for you.

I would agree that the concept of a function (or method) is essential. I
don’t agree that a beginner should be required to understand (or attempt
to
use) blocks to any great extent beyond their role in iteration.

best wishes
Huw C.

http://www.sapphiresteel.com
Ruby P.ming In Visual Studio 2005

Simen E. wrote:

A closure is a function that remembers the environment it was defined
in, and if you don’t understand the concept of a function, programming
is not for you.

Fortunately, I do understand functions. I tend to understand most
things when explained thoroughly and using plain english. Or in the
case of http://poignantguide.net/ruby/ using oddball stories mixed
with tidbits of Ruby code.

The guy is nuts, but I’m enjoying the ride

http://poignantguide.net/ruby/

Whether it is completely correct or not, I like to look at blocks as
little functions that I pass to another function as an argument, just
like I’d pass it a number or another object.

The distinction, though, is how that block of code is called, and that
that block of code can still access the variables you have laying
around where that block of code was called. It’s like rewriting part
of the insides of another function!

As I said, the details are a bit more, well, detailed, and tricky,
too, but, as a very simple explaination, it works.

Now, as a way to get more familiar with it, I’d definitily check out
the Poignant Guide[1] and also _Why[2]'s TryRuby[3] interactive
walkthrough.

M.T.

  1. http://poignantguide.net/
  2. http://redhanded.hobix.com/
  3. http://tryruby.hobix.com/

The owner of the Oriental Theater and I signed on the dotted line
today for the unofficial add-on to the 2006 Ruby Conference.
See rubyrouc.com for more details.
Looking for presenters. Presentations can be via internet video
conferencing
link or via video on DVD. Of course being here live is the cat’s
pajamas.

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AGSC Augustus Gustavius Salvatore Calabrese
4337 Raleigh Street
Denver, CO
720 222 1309 303 908 7716 cell
adding " spam2006 " bypasses my spam blocker. Please place in the
text or at the END of the subject line.
( i am hard to reach by phone )
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

On 8/17/06, He Fa [email protected] wrote:

The guy is nuts, but I’m enjoying the ride
http://poignantguide.net/ruby/

you should watch what you say about _why… I’ve heard he sends his
winged monkeys after people who offend him.

Or someone else does that. Maybe I read it somewhere. What’s
important here is that someone has got monkeys with wings. In a cage,
I assume.

Fortunately, _Why is masterful enough to confuse them with strange
Rubyisms like 10.method(:+).call(20) while obfuscating their mind-code
and enslaving them to dwell on Javacs all day long. That and he feeds
them yummy noodles.

Hail javacs! I mean, _why! I wish you’d appear out of nowhere in
Atlanta at a random coder BBQ! :wink:

M.T.

On Thu, Aug 17, 2006 at 11:53:31AM +0900, Daniel B. wrote:

On 8/17/06, He Fa [email protected] wrote:

The guy is nuts, but I’m enjoying the ride
http://poignantguide.net/ruby/

you should watch what you say about _why… I’ve heard he sends his
winged monkeys after people who offend him.

Or someone else does that. Maybe I read it somewhere. What’s
important here is that someone has got monkeys with wings. In a cage,
I assume.

Not just monkeys – legions of mediocre code monkeys. They’re in
cubicles, not cages. Mostly, it’s Java shops that have those, though.

On 8/16/06, Gus S Calabrese [email protected] wrote:

The owner of the Oriental Theater and I signed on the dotted line
today for the unofficial add-on to the 2006 Ruby Conference.
See rubyrouc.com for more details.
Looking for presenters. Presentations can be via internet video
conferencing
link or via video on DVD. Of course being here live is the cat’s
pajamas.

I notice that you have not yet removed unnecessary attacks on members
of the Ruby community from the website.

Antagonizing the community will win you no friends.

-austin