Merry (slightly early) Christmas! Mr. Neighborly's Humble Little Ruby Book is free!

Hello all,
I just switched everything over, and Mr. Neighborly's Humble Little
Ruby Book is now available to download as a PDF or view online
completely free.

If you don't know about my book: "Mr. Neighborly's Humble Little Ruby
Book covers the Ruby language from the very basics of using puts to
put naughty phrases on the screen all the way to serving up your
favorite web page from WEBrick or connecting to your favorite web
service. Written in a conversational narrative rather than like a dry
reference book, Mr. Neighborly's Humble Little Ruby Book is an easy to
read, easy to follow guide to all things Ruby."

You can go check it out at: http://www.humblelittlerubybook.com/

Enjoy,
Jeremy

P.S. - Yes, I know the HTML is ugly. Blame OpenOffice and my mistake
of using it. The XHTML export filter just crashed OO.org for some
reason, so I'm stuck with the stupid plain HTML exporter which is
terrible.

Jeremy McAnally wrote:

Hello all,

(Look, ma! No top posting!)

"Unlike some other languages, it doesn't get jealous and give you "errors" if you break it off with objects and decide to go steady with closures instead."

Teehee! Thanks for the xmas present! I look forward to checking it out!

(Yes, I'm pretty familiar with Ruby, but I've recently been volunteered to help teach some coworkers, and any time I can delegate work to inanimate objects, I'm happy.)

Devin

Really nice! I'm reading it right now.

I found a small typo on p 26 of the pdf version:

Integers are created by entering the number you wish to use without quotes
(lest it become a string).

--> (lets it become a string).

:slight_smile:

merry christmas
siemen baader

This book is really great! I'm familiar with most of the material already,
but I'm enjoying reading through it all the same. One question I have (a
question of preference more than correctness) is in your example dealing
with blocks and yield, why do you choose to use while with an interator:

def myeach(myarray)
  iter = 0
  while (iter < myarray.length):
    yield(myarray[iter])
    iter += 1
  end
end
testarray = [1,2,3,4,5]
myeach(testarray) {|item| print "#{item}:"}
→ 1:2:3:4:5:

Rather than using what seems (to me at least) the more Ruby way:

def myeach(myarray)
  for elem in myarray
    yield elem
  end
end

That way you're not using an extra variable or having to worry about array
length.

A funny way to write it would be using blocks:
def myeach(myarray)
  myarray.each { |elem| yield(elem) }
end

but I think that way basically defeats the purpose of your example :wink:

Anyway, I'm just interested in your thoughts about this. You most likely
have your reasons and they probably make sense; after all, you're the one
out there writing books :slight_smile:

Thanks and keep up the good work,
Tyler Prete

Jeremy,

Nice book! Easy to read and good explanations.

I found one small error or misleading illustration.

On http://www.humblelittlerubybook.com/book/html/chapter1.html in the
section about ranges the graphic implies that the range 1...7 would include
0 through 6 and the range 1..7 would include 0 through 7. I believe that you
meant to say 1 through 6 and 1 through 7 rather than starting with zero.

Very nice job!!

Jeff

···

On 12/22/06, Jeremy McAnally <jeremymcanally@gmail.com> wrote:

Hello all,
I just switched everything over, and Mr. Neighborly's Humble Little
Ruby Book is now available to download as a PDF or view online
completely free.

You can go check it out at: http://www.humblelittlerubybook.com/

It's OK, it's a typical English subjective tense (which some people claim do
not exist :slight_smile:
"to prevent it from becoming a string"

http://www.oup.com/oald-bin/web_getald7index1a.pl

Pedro.

···

On 12/22/06, Siemen Baader <sbaader@ruc.dk> wrote:

Really nice! I'm reading it right now.

I found a small typo on p 26 of the pdf version:

Integers are created by entering the number you wish to use without quotes
(lest it become a string).

--> (lets it become a string).

:slight_smile:

merry christmas
siemen baader

--
Pedro Fortuny Ayuso
C/Capuchinos 14, 1. 47006 Valladolid. SPAIN

Yeah there are a few grammatical gotcha's that I'm aware of. I'll fix
them when I have time...that's one that no one's pointed out yet
though, so thanks! :slight_smile:

I'm going to put a list of errata up on the site probably sometime
next week; I will correct them all, but it would probably be a good
idea to make you aware of them beforehand. :wink:

--Jeremy

···

On 12/22/06, Siemen Baader <sbaader@ruc.dk> wrote:

Really nice! I'm reading it right now.

I found a small typo on p 26 of the pdf version:

Integers are created by entering the number you wish to use without quotes
(lest it become a string).

--> (lets it become a string).

:slight_smile:

merry christmas
siemen baader

Siemen Baader wrote:

Really nice! I'm reading it right now.

I found a small typo on p 26 of the pdf version:

Integers are created by entering the number you wish to use without quotes
(lest it become a string).

--> (lets it become a string).

:slight_smile:

merry christmas
siemen baader

Now wait just a gosh darn minute! That's not an error. You're simply
not fluent in English. He's saying that to avoid making the number
a string, you must not use quotes.

  Examples from the K.J.V.:

Ye shall not eat of it, neither shall ye touch it, lest ye die.

They shall bear thee up in their hands, lest thou dash thy
foot against a stone.

Also take no heed unto all words that are spoken; lest thou
hear thy servant curse thee:

  A poem by Samuel Taylor Coleridge:

Hear, sweet Spirit, hear the spell,
Lest a blacker charm compel!
So shall the midnight breezes swell
With thy deep long-lingering knell.

And at evening evermore,
In a chapel on the shore,
Shall the chaunter, sad and saintly,
Yellow tapers burning faintly,
Doleful masses chaunt for thee,
  Miserere Domine!

Hush! the cadence dies away
On the quiet moonlight sea:
The boatmen rest their oars and say,
  Miserere Domine!

···

--
Q. What's long and round and full of siemen?
A. A submarine.

This book is really great! I'm familiar with most of the material already,
but I'm enjoying reading through it all the same. One question I have (a
question of preference more than correctness) is in your example dealing
with blocks and yield, why do you choose to use while with an interator:

def myeach(myarray)
  iter = 0
  while (iter < myarray.length):
    yield(myarray[iter])
    iter += 1
  end
end
testarray = [1,2,3,4,5]
myeach(testarray) {|item| print "#{item}:"}
→ 1:2:3:4:5:

Rather than using what seems (to me at least) the more Ruby way:

def myeach(myarray)
  for elem in myarray
    yield elem
  end
end

That way you're not using an extra variable or having to worry about array
length.

A funny way to write it would be using blocks:
def myeach(myarray)
  myarray.each { |elem| yield(elem) }
end

but I think that way basically defeats the purpose of your example :wink:

"for i in collection" is converted by the parser to collection.each do

i>, so it comes to the same thing as your last example (:

martin

···

On 12/23/06, Tyler Prete <psyonic@gmail.com> wrote:

Hey Tyler,
While thats the most Rubyish way to do it, at that point in the text I
hadn't covered those sorts of loops/iterators yet and thought that the
while method would be more familiar to those reading. I may change it
in the next revision, but I'm not sure. :slight_smile:

--Jeremy

···

On 12/22/06, Tyler Prete <psyonic@gmail.com> wrote:

This book is really great! I'm familiar with most of the material already,
but I'm enjoying reading through it all the same. One question I have (a
question of preference more than correctness) is in your example dealing
with blocks and yield, why do you choose to use while with an interator:

def myeach(myarray)
  iter = 0
  while (iter < myarray.length):
    yield(myarray[iter])
    iter += 1
  end
end
testarray = [1,2,3,4,5]
myeach(testarray) {|item| print "#{item}:"}
→ 1:2:3:4:5:

Rather than using what seems (to me at least) the more Ruby way:

def myeach(myarray)
  for elem in myarray
    yield elem
  end
end

That way you're not using an extra variable or having to worry about array
length.

A funny way to write it would be using blocks:
def myeach(myarray)
  myarray.each { |elem| yield(elem) }
end

but I think that way basically defeats the purpose of your example :wink:

Anyway, I'm just interested in your thoughts about this. You most likely
have your reasons and they probably make sense; after all, you're the one
out there writing books :slight_smile:

Thanks and keep up the good work,
Tyler Prete

>
> Hello all,
> I just switched everything over, and Mr. Neighborly's Humble Little
> Ruby Book is now available to download as a PDF or view online
> completely free.
>
> You can go check it out at: http://www.humblelittlerubybook.com/
>

Jeremy,

Another suggestion is to clarify your statement in regards to conditional
link operators on
http://www.humblelittlerubybook.com/book/html/chapter3.html

You mention that the stringified versions (and,or, not) are the same as the
C version (&&, ||, !) but there is a pretty big gotcha that can occur if you
treat these the same. The stringified versions are very low priority and
thus operators like = will end up evaluating first. This could lead to some
hard to track down bugs, so it is important to make the distinction.
Obviously the developer can force their desired priority using parentheses
but they should at least know the difference. The rails core team has
guidelines such that they recommend developers not use the stringified
versions probably to avoid these very bugs.

The following is from another post on Ruby Gotchas referencing an example
from Hal Fulton's book.

foo = false
bar = true

baz = foo or bar

baz ends up false (because = has greater priority than or)

Why would anyone want = to be evaluated before anything
else?

The point is that 'or' and 'and' have /lower/ precedence than
anything else, so that they can be used to chain complete expressions
together.

Blessings,

Jeff

···

On 12/22/06, Jeremy McAnally <jeremymcanally@gmail.com> wrote:

I'm going to put a list of errata up on the site probably sometime
next week; I will correct them all, but it would probably be a good
idea to make you aware of them beforehand. :wink:

Sure :slight_smile:

William James wrote:

> Now wait just a gosh darn minute! That's not an error. You're simply
> not fluent in English. He's saying that to avoid making the number
> a string, you must not use quotes.

You're right! I didn't really get that before your explanation - it makes perfect sense this way. Thanks.

Q. What's long and round and full of siemen?
A. A submarine.

Hm... I think the first part of your post was the more gifted one. But no hard feelings.

Merry Christmas to you as well,
Siemen

Hi --

···

On Tue, 26 Dec 2006, Jeremy McAnally wrote:

On 12/22/06, Tyler Prete <psyonic@gmail.com> wrote:

This book is really great! I'm familiar with most of the material already,
but I'm enjoying reading through it all the same. One question I have (a
question of preference more than correctness) is in your example dealing
with blocks and yield, why do you choose to use while with an interator:

def myeach(myarray)
  iter = 0
  while (iter < myarray.length):
    yield(myarray[iter])
    iter += 1
  end
end
testarray = [1,2,3,4,5]
myeach(testarray) {|item| print "#{item}:"}
¢ª 1:2:3:4:5:

Rather than using what seems (to me at least) the more Ruby way:

def myeach(myarray)
  for elem in myarray
    yield elem
  end
end

That way you're not using an extra variable or having to worry about array
length.

A funny way to write it would be using blocks:
def myeach(myarray)
  myarray.each { |elem| yield(elem) }
end

but I think that way basically defeats the purpose of your example :wink:

Anyway, I'm just interested in your thoughts about this. You most likely
have your reasons and they probably make sense; after all, you're the one
out there writing books :slight_smile:

Hey Tyler,
While thats the most Rubyish way to do it, at that point in the text I
hadn't covered those sorts of loops/iterators yet and thought that the
while method would be more familiar to those reading. I may change it
in the next revision, but I'm not sure. :slight_smile:

I definitely agree that that -- dealing with forward topic references
as one writes -- is a challenge. My favorite example is: you can't
really explain Enumerable until you've explained arrays, but Array is
Enumerable.... :slight_smile: It is, though, a good affirmation of the fact that
Ruby is a nicely integrated system and a well-oiled machine.

David

--
Q. What's a good holiday present for the serious Rails developer?
A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black\)
    aka The Ruby book for Rails developers!
Q. Where can I get Ruby/Rails on-site training, consulting, coaching?
A. Ruby Power and Light, LLC (http://www.rubypal.com)

Jeremy,

Thanks for the response. That makes sense to try and use/leverage what
people are likely to already know, and a C-style while loop would definitely
be one of those things. I was thinking more along the lines of someone
coming fresh to programming, where it might be more useful to teach them the
nice clean ways we have of doing things up front and to help them avoid
off-by-one errors and things like it.

Thanks,
Tyler Prete

···

On 12/25/06, Jeremy McAnally <jeremymcanally@gmail.com> wrote:

Hey Tyler,
While thats the most Rubyish way to do it, at that point in the text I
hadn't covered those sorts of loops/iterators yet and thought that the
while method would be more familiar to those reading. I may change it
in the next revision, but I'm not sure. :slight_smile:

--Jeremy

On 12/22/06, Tyler Prete <psyonic@gmail.com> wrote:
> This book is really great! I'm familiar with most of the material
already,
> but I'm enjoying reading through it all the same. One question I have
(a
> question of preference more than correctness) is in your example dealing
> with blocks and yield, why do you choose to use while with an interator:
>
> def myeach(myarray)
> iter = 0
> while (iter < myarray.length):
> yield(myarray[iter])
> iter += 1
> end
> end
> testarray = [1,2,3,4,5]
> myeach(testarray) {|item| print "#{item}:"}
> → 1:2:3:4:5:
>
> Rather than using what seems (to me at least) the more Ruby way:
>
> def myeach(myarray)
> for elem in myarray
> yield elem
> end
> end
>
> That way you're not using an extra variable or having to worry about
array
> length.
>
> A funny way to write it would be using blocks:
> def myeach(myarray)
> myarray.each { |elem| yield(elem) }
> end
>
> but I think that way basically defeats the purpose of your example :wink:
>
> Anyway, I'm just interested in your thoughts about this. You most
likely
> have your reasons and they probably make sense; after all, you're the
one
> out there writing books :slight_smile:
>
> Thanks and keep up the good work,
> Tyler Prete
>