Exiting a loop

I note that one of the big online book stores has used copies available
for less than $10.00. Less than the cost of a CD. Less than a movie ticket
plus popcorn. Less than a stack of 50 blank CD-Rs.

I don’t buy CDs, I’ve never bought a stack of 50 blank CD-Rs, I almost
never go to the movies and I absolutely never buy popcorn

There really is no excuse for NOT having a paper copy of the book.

Oh, there is. If someone is not satisfied with it that is a good reason
not to buy it.

I’m sure that many people (most?) like PickAxe best. But I don’t. Maybe
it’s not the style of book I like, who knows? But this is a good reason
for not having it.

···

On Mon, Mar 24, 2003 at 04:53:06AM +0900, Tim Hunter wrote:


Daniel Carrera
Graduate Teaching Assistant. Math Dept.
University of Maryland. (301) 405-5137

dudgeon: dudgeon (DUHJ-uhn) noun

A feeling of anger, resentment, indignation, etc.

Point taken, Gavin. :slight_smile:

But his example showed one simple loop.
It seemed from context that he didn’t
know about break. Catch/throw is nice,
but he does need to know about break.

Hal

···

----- Original Message -----
From: “Gavin Sinclair” gsinclair@soyabean.com.au
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Tuesday, March 25, 2003 12:58 AM
Subject: Re: exiting a loop

What’s wrong with a simple ‘break’? :slight_smile:

To swat a fly, use a flyswatter.

catch(:finished) do
while cond1
while cond2
while cond3
while cond4

while cond99
throw :finished if cond100
end

end
end
end
end
end

Yes - it’s around, but I withdrew the links after someone tool it and
changed the license terms.

I you’d like to work on it, send me an e-mail and I’ll get you set up.,

Cheers

Dave

···

On Sunday, Mar 23, 2003, at 13:15 US/Central, Brian Candler wrote:

I don’t suppose the original source is around? So for example we could
take
references to “page 461” and turn them into hyperlinks?

Oh, there is. If someone is not satisfied with it that is a good reason
not to buy it.

I’m sure that many people (most?) like PickAxe best. But I don’t. Maybe
it’s not the style of book I like, who knows? But this is a good reason
for not having it.

···

----- Original Message -----

Have you tried reading chapter 18: The Ruby Language? It’s not even 40
pages and answers most every question you have asked on the ML. If you have
been scanning through the electronic version not knowing where to look,
having people constantly responding with “read the pickaxe”, then your
frustration is understandable. However, look it over. It’s the most
concise and complete description of the Ruby language I have come across.

Plus, their class reference has been invaluable. Do you use a different
class reference? Are you sure it didn’t originate from the electronic
version of the Pickaxe? I’m sure that, even though you may not like the
book for whatever reasons, you are probably indebted to it in some way,
though you were never asked to spend a dime for it.

How is it that you know about Ruby in the first place? Most likely it is
because of the Pragmatic Programmers, either directly or indirectly. You
probably read the Dr. Dobbs article, or heard about Ruby from someone who
read it.

Credit where credit’s due,

Chris

Have you tried reading chapter 18: The Ruby Language?

I think I’ve read it (or at least skimmed it) in the past. Thanks for the
pointer.

However, one chapter is hardly a full reference. Gavin is right. I
was mistakenly expecting PickAxe to be a reference, but that’s not its
purpose.

Plus, their class reference has been invaluable. Do you use a different
class reference?

The class reference is good. When I need a class reference I usually use
one of the following:

  1. PickAxe class reference
  2. Ruby’s “ri” program.
  3. To learn about class ‘SomeClass’:

ruby -e ‘puts SomeClass.new.methods.sort’ | less

You’d be surprised how often I end up doing (3). But I think that (2) is
the most common.

I’m sure that, even though you may not like the book for whatever
reasons, you are probably indebted to it in some way, though you were
never asked to spend a dime for it.

Oh, I never meant to “bash” the book. It’s a great addition to the Ruby
community. Yes, I’ve learned much from it. It just happens that, as
Gavin pointed out, what I most often want from a book is not what PickAxe
was meant to provide.

How is it that you know about Ruby in the first place? Most likely it is
because of the Pragmatic Programmers, either directly or indirectly.

Someone wrote an article in “Linux Managinze” (or was it “The Linux
Journal”?). Since I was looking a replacement for Perl, I decided to
investigate.

You probably read the Dr. Dobbs article, or heard about Ruby from
someone who read it.

Maybe it was him (her?). What does this have to do with PickAxe?

Credit where credit’s due,

Certainly. But I don’t see how my saying that I don’t like it discredits
the book in any way. I have honestly struggled to learn from it, and have
been frustrated at finding so few alternatives. My frustration with Ruby
documentation is part of my motivation for writing an introductory
tutorial.

I am very grateful to David Thomas and Andrew Hunt for the work the put in
in creating this book. My personal preference in writing style and book
format does not, in any way, diminish the value of this contribution, or
my gratitude for it.

···

On Mon, Mar 24, 2003 at 01:13:33PM +0900, Chris Pine wrote:


Daniel Carrera
Graduate Teaching Assistant. Math Dept.
University of Maryland. (301) 405-5137

dudgeon: dudgeon (DUHJ-uhn) noun

A feeling of anger, resentment, indignation, etc.

i end up doing something like this too, only i usually use :

ruby -e ‘puts SomeClass.new.methods.sort - Object.new.methods.sort’ | less

to weed out all but the unique ones.

-a

···

On Mon, 24 Mar 2003, Daniel Carrera wrote:

  1. To learn about class ‘SomeClass’:

ruby -e ‘puts SomeClass.new.methods.sort’ | less

You’d be surprised how often I end up doing (3). But I think that (2) is
the most common.

Ara Howard
NOAA Forecast Systems Laboratory
Information and Technology Services
Data Systems Group
R/FST 325 Broadway
Boulder, CO 80305-3328
Email: ahoward@fsl.noaa.gov
Phone: 303-497-7238
Fax: 303-497-7259
====================================

Dave Thomas created ‘ri’. All its data comes from the Pickaxe! :wink:

Gavin

···

On Monday, March 24, 2003, 4:09:17 PM, Daniel wrote:

Plus, their class reference has been invaluable. Do you use a different
class reference?

The class reference is good. When I need a class reference I usually use
one of the following:

  1. PickAxe class reference
  2. Ruby’s “ri” program.
  3. To learn about class ‘SomeClass’:

ruby -e ‘puts SomeClass.new.methods.sort’ | less

You’d be surprised how often I end up doing (3). But I think that (2) is
the most common.

I didn’t think of that. I just wrote this one-line script:

···

On Mon, Mar 24, 2003 at 04:16:24PM +0900, ahoward wrote:

i end up doing something like this too, only i usually use :

ruby -e ‘puts SomeClass.new.methods.sort - Object.new.methods.sort’ | less

to weed out all but the unique ones.


#!/bin/sh

File name: methods

ruby -e ‘puts ‘$1’.new.methods.sort - Object.new.methods.sort’ | less

So I can just type “methods String” on a terminal.


Daniel Carrera
Graduate Teaching Assistant. Math Dept.
University of Maryland. (301) 405-5137

No longer a one-liner, but value-add. For bonus points,
allow specification of private, protected, singleton, etc methods.

#!/usr/bin/env ruby -w

Print unique methods and their arity

···

Daniel Carrera (dcarrera@math.umd.edu) wrote:

I didn’t think of that. I just wrote this one-line script:

#!/bin/sh

File name: methods

ruby -e ‘puts ‘$1’.new.methods.sort - Object.new.methods.sort’ | less

So I can just type “methods String” on a terminal.

Can also do ruby -r methods

require ‘open3’

obj = eval(ARGV.shift).new

methods = obj.methods.sort - Object.new.methods.sort

methods.collect! do |meth|
“#{meth}: #{obj.method(meth).arity} arguments”
end

IO.popen(‘less’, ‘w’) do |less|
less.puts “Methods for #{obj.class}”
less.puts methods.join($/)
end


Eric Hodel - drbrain@segment7.net - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04

Daniel Carrera wrote:

i end up doing something like this too, only i usually use :

ruby -e ‘puts SomeClass.new.methods.sort - Object.new.methods.sort’ | less

to weed out all but the unique ones.

I didn’t think of that. I just wrote this one-line script:

#!/bin/sh

File name: methods

ruby -e ‘puts ‘$1’.new.methods.sort - Object.new.methods.sort’ | less

So I can just type “methods String” on a terminal.

Nice. More focused than ‘ri String’.

It might be better to use Module#instance_methods. It takes a boolean
arg that determines if superclasses are included, but you might still
want to do the subtraction. What this would save you is actually
instantiating an object, which might fail for lack of arguments, and
anyway who knows what instantiating the class does (fork a web server
maybe?).

···

On Mon, Mar 24, 2003 at 04:16:24PM +0900, ahoward wrote:

I extended it some more (file is attached). I added:

  • Pretty printing.
  • Can specify private/public/singleton methods
  • Can ‘require’ libraries without typing ‘ruby -r lib methods …’
  • Limited ability to examine classes that require input paramters to
    initialize (e.g. PStore → store = PStore.new(“file”) ).

USAGE: methods [options] Class
BUGS: doesn’t work if the parameters of Class.new are not strings.

Examples:
methods String
methods --private --singleton String
methods --require tk TkRoot
methods --singleton -r tk TkRoot

Available options:
–require, -r Require libraries.
–private Print private methods
–public Print public methods
–singleton Print singleton methods

If none of --private, --public, --singleton is specified, public methods
are printed.

Example output ‘methods String’ (snipped):

Methods for String

methods (2.88 KB)

···

On Tue, Mar 25, 2003 at 09:32:28AM +0900, Eric Hodel wrote:

No longer a one-liner, but value-add. For bonus points,
allow specification of private, protected, singleton, etc methods.

==================

Method Arguments

%                   1
*                   1
+                   1
<                   1
[snip]

Example output 'methods -r pstore PStore "file"' (snipped):

Methods for PStore
==================

Method         Arguments
~~~~~~~~~~~    ~~~~~~~~~
[]              1
[]=             2
abort           0
commit          0


-- 
Daniel Carrera
Graduate Teaching Assistant.  Math Dept.
University of Maryland.  (301) 405-5137

</details>