[#267026] attr_reader — 7stud 7stud <dolgun@...>

On p. 30-31 of "Programming Ruby (2nd ed)", there is this example:

15 messages 2007/09/01

[#267065] Seeing the source — Michel Cabili <michel.cabili@...>

Hello. I'm new to Ruby (and also to scripting languages).

38 messages 2007/09/01

[#267086] Help with leap year programing — HB <hbqian@...>

Hi, All,

19 messages 2007/09/01

[#267106] Singleton Modules rather than Singleton Classes — Trans <transfire@...>

This recently came up in the thread entitled "Python-style

14 messages 2007/09/01

[#267113] Parsing query parameters from hyperlink — "lrlebron@..." <lrlebron@...>

I am trying to parse strings like this

11 messages 2007/09/01
[#267128] Re: Parsing query parameters from hyperlink — Robert Klemme <shortcutter@...> 2007/09/01

On 01.09.2007 19:34, lrlebron@gmail.com wrote:

[#267184] How does ruby handle overloading? — pongba <pongba@...>

Matz once replied on Cedric's blog that

13 messages 2007/09/02

[#267261] subject line — "Devi Web Development" <devi.webmaster@...>

I don't know who would make this sort of decision, but could we put

103 messages 2007/09/02
[#267397] Re: subject line — Trans <transfire@...> 2007/09/03

[#267633] Re: subject line — Chad Perrin <perrin@...> 2007/09/04

On Tue, Sep 04, 2007 at 04:01:56AM +0900, Trans wrote:

[#267655] Re: subject line — Trans <transfire@...> 2007/09/04

[#267656] Re: subject line — Chad Perrin <perrin@...> 2007/09/04

On Wed, Sep 05, 2007 at 08:54:22AM +0900, Trans wrote:

[#267665] Re: subject line — "Rimantas Liubertas" <rimantas@...> 2007/09/05

> Any time you tell someone to completely change the tools (s)he uses,

[#267744] Re: subject line — Chad Perrin <perrin@...> 2007/09/05

On Wed, Sep 05, 2007 at 10:12:53AM +0900, Rimantas Liubertas wrote:

[#267266] Re: subject line — Dan Zwell <dzwell@...> 2007/09/02

Devi Web Development wrote:

[#267481] Re: subject line — Bil Kleb <Bil.Kleb@...> 2007/09/04

Chad Perrin wrote:

[#267506] Re: subject line — John Joyce <dangerwillrobinsondanger@...> 2007/09/04

Respectfully, no, unless it's very short. I suggest sort by the To:

[#267510] Re: subject line — "Robert Klemme" <shortcutter@...> 2007/09/04

I vote against, basically because I believe the issue can be solved

[#267514] Re: subject line — "Peter Cooper" <peter@...> 2007/09/04

I vote against. Those with the firehose of ruby-talk gushing into their

[#267282] assigning to hash keys when there is a default value? — 7stud -- <dolgun@...>

Can someone explain why there is a difference in the second line of

41 messages 2007/09/03
[#267283] Re: assigning to hash keys when there is a default value? — dblack@... 2007/09/03

Hi --

[#267286] Re: assigning to hash keys when there is a default value? — 7stud -- <dolgun@...> 2007/09/03

unknown wrote:

[#267310] Re: assigning to hash keys when there is a default value? — Peña, Botp <botp@...> 2007/09/03

From: 7stud -- [mailto:dolgun@excite.com]

[#267330] Re: assigning to hash keys when there is a default value? — 7stud -- <dolgun@...> 2007/09/03

Pe単a, Botp wrote:

[#267335] Re: assigning to hash keys when there is a default value? — "Russell Norris" <rsl@...> 2007/09/03

I don't think this is a bug, kittens. since h[2] returns a value [eventhough it's not set], it causes h[2] to evaluate so the assignmentnever happens. x ||= y just means give me x or set x to y if there'sno value for x. h[2] _does_ have a value if only a default one.

[#267338] Re: assigning to hash keys when there is a default value? — dblack@... 2007/09/03

Hi --

[#267344] Re: assigning to hash keys when there is a default value? — "Russell Norris" <rsl@...> 2007/09/03

I learned that x ||= y means set x to y unless x, so I don't see the

[#267431] Re: assigning to hash keys when there is a default value? — Peña, Botp <botp@...> 2007/09/04

From: sconds@gmail.com [mailto:sconds@gmail.com] On Behalf Of Russell Norris:

[#267511] Re: assigning to hash keys when there is a default value? — "Robert Klemme" <shortcutter@...> 2007/09/04

2007/9/4, Pe, Botp <botp@delmonte-phil.com>:

[#267325] Re: assigning to hash keys when there is a default value? — "Robert Klemme" <shortcutter@...> 2007/09/03

2007/9/3, dblack@wobblini.net <dblack@wobblini.net>:

[#267318] Filling individual cells in a grid — Joop Van den tillaart <tillaart36@...>

Hi guys,

32 messages 2007/09/03
[#267326] Re: Filling individual cells in a grid — "Todd Benson" <caduceass@...> 2007/09/03

On 9/3/07, Joop Van den tillaart <tillaart36@hotmail.com> wrote:

[#267329] Re: Filling individual cells in a grid — Joop Van den tillaart <tillaart36@...> 2007/09/03

> With your current code...

[#267341] Re: Filling individual cells in a grid — Joop Van den tillaart <tillaart36@...> 2007/09/03

Is there no one else who can help me out a bit?

[#267348] Re: Filling individual cells in a grid — Morton Goldberg <m_goldberg@...> 2007/09/03

On Sep 3, 2007, at 8:40 AM, Joop Van den tillaart wrote:

[#267363] Re: Filling individual cells in a grid — Joop Van den tillaart <tillaart36@...> 2007/09/03

Wow, thanks for your help...

[#267868] Re: Filling individual cells in a grid — Joop Van den tillaart <tillaart36@...> 2007/09/06

Joop Van den tillaart wrote:

[#267885] Re: Filling individual cells in a grid — Morton Goldberg <m_goldberg@...> 2007/09/06

On Sep 6, 2007, at 7:44 AM, Joop Van den tillaart wrote:

[#267899] Re: Filling individual cells in a grid — Joop Van den tillaart <tillaart36@...> 2007/09/06

hi thanks for your help,

[#267964] Re: Filling individual cells in a grid — Morton Goldberg <m_goldberg@...> 2007/09/06

On Sep 6, 2007, at 11:38 AM, Joop Van den tillaart wrote:

[#267984] Re: Filling individual cells in a grid — Morton Goldberg <m_goldberg@...> 2007/09/06

On Sep 6, 2007, at 4:47 PM, Morton Goldberg wrote:

[#268074] Re: Filling individual cells in a grid — Joop Van den tillaart <tillaart36@...> 2007/09/07

Morton Goldberg wrote:

[#268630] Re: Filling individual cells in a grid — Joop Van den tillaart <tillaart36@...> 2007/09/11

Hi guys,

[#268645] Re: Filling individual cells in a grid — Morton Goldberg <m_goldberg@...> 2007/09/11

[#268647] Re: Filling individual cells in a grid — Joop Van den tillaart <tillaart36@...> 2007/09/11

Morton Goldberg wrote:

[#268677] Re: Filling individual cells in a grid — Morton Goldberg <m_goldberg@...> 2007/09/11

On Sep 11, 2007, at 7:57 AM, Joop Van den tillaart wrote:

[#268695] Re: Filling individual cells in a grid — Morton Goldberg <m_goldberg@...> 2007/09/11

On Sep 11, 2007, at 2:03 PM, Morton Goldberg wrote:

[#268705] Re: Filling individual cells in a grid — Morton Goldberg <m_goldberg@...> 2007/09/11

On Sep 11, 2007, at 4:34 PM, Morton Goldberg wrote:

[#267357] with — Matthias Wächter <matthias@...>

Sorry folks if this was raised already, but google is not very

14 messages 2007/09/03

[#267370] wierd floating point output — Matthias Wächter <matthias@...>

Folks,

14 messages 2007/09/03
[#267371] Re: wierd floating point output — dblack@... 2007/09/03

Hi --

[#267373] Re: wierd floating point output — Matthias Wächter <matthias@...> 2007/09/03

On 03.09.2007 19:51, dblack@wobblini.net wrote:

[#267433] Programming Ruby For Newbies — Jin Dynasty <jin.the.miner@...>

Howdy there,

25 messages 2007/09/04

[#267457] Ruby is much slower on linux when compiled with --enable-pthread? — "Adam Kramer" <akramer@...>

Hi,

18 messages 2007/09/04

[#267469] Best IDE for ruby and rails development — AJay Maurya <amaurya@...>

36 messages 2007/09/04
[#267471] Re: Best IDE for ruby and rails development — "Thomas Preymesser" <thopre@...> 2007/09/04

On 04/09/07, AJay Maurya <amaurya@brickred.com> wrote:

[#267476] Re: Best IDE for ruby and rails development — Arthur Murauskas <arthur.murauskas@...> 2007/09/04

On Tuesday 04 September 2007 10:31:23 AJay Maurya wrote:

[#267569] running ruby — yahdoco <yahdoco@...>

Hi Everyone...I am a very new ruby user. I have downloaded ruby to my

28 messages 2007/09/04
[#267574] Re: running ruby — Konrad Meyer <konrad@...> 2007/09/04

On Tuesday 04 September 2007 11:20:05 am yahdoco wrote:

[#267594] Re: running ruby — yahdoco <yahdoco@...> 2007/09/04

I sill have the same two problems:

[#267573] Embedded vs. Non-embedded Tests — Trans <transfire@...>

As far as I know, Facets is the only large project that uses embedded

14 messages 2007/09/04
[#267579] Re: Embedded vs. Non-embedded Tests — "Rick DeNatale" <rick.denatale@...> 2007/09/04

On 9/4/07, Trans <transfire@gmail.com> wrote:

[#267723] Multiple Assignments: Newbie question — "Z T" <zoater@...>

When I run my program:

15 messages 2007/09/05

[#267783] before, after and around Ruby 1.9 — Trans <transfire@...>

Any chance Ruby 1.9 will have before, after and around method

40 messages 2007/09/05
[#267816] Re: before, after and around Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/09/05

Hi,

[#267825] Re: before, after and around Ruby 1.9 — Joel VanderWerf <vjoel@...> 2007/09/06

Yukihiro Matsumoto wrote:

[#267797] question on bottleneck of ruby — Roger Pack <rogerpack2005@...>

Question: if I made the statement "Ruby is slower than some other

26 messages 2007/09/05
[#267807] Re: question on bottleneck of ruby — khaines@... 2007/09/05

On Thu, 6 Sep 2007, Roger Pack wrote:

[#271288] Re: question on bottleneck of ruby — Roger Pack <rogerpack2005@...> 2007/09/27

Thanks Kirk.

[#271298] Re: question on bottleneck of ruby — "Francis Cianfrocca" <garbagecat10@...> 2007/09/27

On 9/27/07, Roger Pack <rogerpack2005@gmail.com> wrote:

[#267857] Symbols and frozen strings — Brian Candler <B.Candler@...>

I just had a thought.

13 messages 2007/09/06

[#267871] Count and Say (#138) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

21 messages 2007/09/06

[#267941] Is this a bug or a feature? — Martin Jansson <martialis@...>

irb(main):002:0> i=1

13 messages 2007/09/06

[#268006] help me condence my code? — "Simon Schuster" <significants@...>

I know this could be more idiomatic to ruby.

23 messages 2007/09/07

[#268052] read a specific line from a file — Bulhac Mihai <mihai.bulhac@...>

how can i read only a line from a txt file?

18 messages 2007/09/07

[#268108] Netbeans, Eclipse and ruby! How to...? — "André Cardoso" <thyandrecardoso@...>

well, i should start to say that i'm pretty new to ruby!!

15 messages 2007/09/07

[#268307] Bug in lambda? — kevin cline <kevin.cline@...>

This looks like a pretty serious bug. It seems that lambda-

36 messages 2007/09/09
[#268323] Re: Bug in lambda? — dblack@... 2007/09/09

Hi --

[#268485] Re: Bug in lambda? — "Robert Klemme" <shortcutter@...> 2007/09/10

2007/9/9, dblack@wobblini.net <dblack@wobblini.net>:

[#268316] module_function :func vs. MyModule.func? — 7stud -- <dolgun@...>

The following produce the same output:

16 messages 2007/09/09

[#268362] Hash — Ron Green <rongreen1@...>

What is the purpose of string hash? What would you use it for?

21 messages 2007/09/09

[#268403] What Linux distribution to choose for learning Ruby and Ruby on Rails — "Slavo Furman" <slavof@...>

Hi!

82 messages 2007/09/09
[#268413] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/09

-----BEGIN PGP SIGNED MESSAGE-----

[#268418] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "Slavo Furman" <slavof@...> 2007/09/09

Thanks for all answers... :)

[#268425] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/10

-----BEGIN PGP SIGNED MESSAGE-----

[#268427] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Reid Thompson <reid.thompson@...> 2007/09/10

M. Edward (Ed) Borasky wrote:

[#268439] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/10

-----BEGIN PGP SIGNED MESSAGE-----

[#268444] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Reid Thompson <reid.thompson@...> 2007/09/10

M. Edward (Ed) Borasky wrote:

[#268451] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/10

-----BEGIN PGP SIGNED MESSAGE-----

[#268545] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Ezra Zygmuntowicz <ezmobius@...> 2007/09/10

Hi~

[#268595] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/11

-----BEGIN PGP SIGNED MESSAGE-----

[#268606] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Chad Perrin <perrin@...> 2007/09/11

On Tue, Sep 11, 2007 at 12:00:57PM +0900, M. Edward (Ed) Borasky wrote:

[#268611] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/11

-----BEGIN PGP SIGNED MESSAGE-----

[#268614] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — bob@... (Bob Proulx) 2007/09/11

M. Edward (Ed) Borasky wrote:

[#268405] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Marcin Raczkowski <mailing.mr@...> 2007/09/09

Slavo Furman wrote:

[#268750] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — hemant <gethemant@...> 2007/09/12

On 9/10/07, Marcin Raczkowski <mailing.mr@gmail.com> wrote:

[#269173] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "Shot (Piotr Szotkowski)" <shot@...> 2007/09/15

hemant:

[#269182] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "Todd Benson" <caduceass@...> 2007/09/15

On 9/15/07, Shot (Piotr Szotkowski) <shot@hot.pl> wrote:

[#269199] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/15

Todd Benson wrote:

[#268433] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Trans <transfire@...> 2007/09/10

[#268436] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/10

-----BEGIN PGP SIGNED MESSAGE-----

[#268447] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Trans <transfire@...> 2007/09/10

[#268513] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Chad Perrin <perrin@...> 2007/09/10

On Mon, Sep 10, 2007 at 12:07:42PM +0900, Trans wrote:

[#268517] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Lionel Bouton <lionel-subscription@...> 2007/09/10

Chad Perrin wrote the following on 10.09.2007 18:46 :

[#268539] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Chad Perrin <perrin@...> 2007/09/10

On Tue, Sep 11, 2007 at 01:54:42AM +0900, Lionel Bouton wrote:

[#268557] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Lionel Bouton <lionel-subscription@...> 2007/09/10

Thanks for the answer, that was an interesting reading. I've some

[#268565] Re: [OT] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Chad Perrin <perrin@...> 2007/09/10

On Tue, Sep 11, 2007 at 05:38:32AM +0900, Lionel Bouton wrote:

[#268570] Re: [OT] Re: What Linux distribution to choose for learning Ruby and Ruby on Rails — Chad Perrin <perrin@...> 2007/09/10

On Tue, Sep 11, 2007 at 07:00:50AM +0900, Chad Perrin wrote:

[#268658] undefined method `+' for nil:NilClass (NoMeth — Mahen Surinam <neoanderson12@...>

Dear All,

14 messages 2007/09/11

[#268663] Camping or Merb — "Eduardo Tongson" <propolice@...>

Hi folks,

19 messages 2007/09/11

[#268672] Graphics... why so shrouded in mystery? — Weston Campbell <silvershockwave@...>

I've been working with ruby for quite a while now, and I still don't

13 messages 2007/09/11

[#268761] what is this syntax: \001\002 ? — 7stud -- <dolgun@...>

Hi,

15 messages 2007/09/12

[#268786] copy/paste line numbers with code — Max Williams <toastkid.williams@...>

I'm writing up my project report and want to include line numbers with

12 messages 2007/09/12

[#268802] IronRuby — Lloyd Linklater <lloyd@2live4.com>

I have heard disturbing things about IronRuby. The short version is

36 messages 2007/09/12
[#268828] Re: IronRuby — Greg Donald <greg@...> 2007/09/12

On Thu, 13 Sep 2007, Lloyd Linklater wrote:

[#268833] Re: IronRuby — "Felix Windt" <fwmailinglists@...> 2007/09/12

> -----Original Message-----

[#268911] Re: IronRuby — Charles Oliver Nutter <charles.nutter@...> 2007/09/13

Bill Kelly wrote:

[#268918] Debug — "coolgeng coolgeng" <coolgeng410@...>

With the Rails, I build a project connecting the MySQL. But When I change

17 messages 2007/09/13

[#268970] Cross-platform Home Directory? — Trans <transfire@...>

I have a little app that needs to store session data. I assume the

19 messages 2007/09/13

[#269047] IP to Country (#139) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

32 messages 2007/09/14

[#269063] How many computers in the house? — Todd Burch <promos@...>

I went to the Lone Star Ruby Conference last week. 7 of us went out to

41 messages 2007/09/14

[#269125] Unicode — Zephyr Pellerin <ztz@...>

I hate to discuss something related to the development timeline, I know

26 messages 2007/09/15
[#270180] Re: Unicode — "Michal Suchanek" <hramrach@...> 2007/09/21

On 15/09/2007, Zephyr Pellerin <ztz@nxvr.org> wrote:

[#269140] one line to print the statement AS WELL AS the evaluated value like in C — kendear <summercoolness@...>

i wonder in Ruby, is there a line method to do something like in C

11 messages 2007/09/15

[#269214] Newbie help — Ali Koubeissi <ali.koubeissi@...>

Hey, I've started with Ruby two days ago, and I have some questions.

19 messages 2007/09/16

[#269251] Ruby Forum > Ruby Talk > comp.lang.ruby ? — Kenneth LL <kenneth.kin.lum@...>

so it seems like Google created Ruby Talk and anything posted to Ruby

25 messages 2007/09/16

[#269315] Newbie: what's Ruby idiom for word-by-word input? — Alex Shulgin <alex.shulgin@...>

Hi,

16 messages 2007/09/16
[#269326] Re: Newbie: what's Ruby idiom for word-by-word input? — Robert Klemme <shortcutter@...> 2007/09/16

On 16.09.2007 21:08, Alex Shulgin wrote:

[#269407] Re: Newbie: what's Ruby idiom for word-by-word input? — Alex Shulgin <alex.shulgin@...> 2007/09/17

On Sep 17, 12:19 am, Robert Klemme <shortcut...@googlemail.com> wrote:

[#269441] Re: Newbie: what's Ruby idiom for word-by-word input? — William James <w_a_x_man@...> 2007/09/17

On Sep 17, 4:30 am, Alex Shulgin <alex.shul...@gmail.com> wrote:

[#269357] Tk Ruby / Fx Ruby / Wx Ruby — "Jayson Williams" <williams.jayson@...>

I have looked at these three GUI's for Ruby, and would like to know

12 messages 2007/09/17

[#269440] group array elements in groups of two — Emmanuel Oga <oga_emmanuel_oga@...>

A better way to do this? :

13 messages 2007/09/17

[#269450] how to use tuple as hash key — SpringFlowers AutumnMoon <summercoolness@...>

in Python, a hash key cannot be [1,2,3] but must be (1,2,3), a tuple.

13 messages 2007/09/17
[#269453] Re: how to use tuple as hash key — Stefano Crocco <stefano.crocco@...> 2007/09/17

Alle luned狸 17 settembre 2007, SpringFlowers AutumnMoon ha scritto:

[#269562] The meaning of a = b in object oriented languages — Summercool <Summercoolness@...>

30 messages 2007/09/18

[#269596] finding string matches, in order, in a file — Peter Bailey <pbailey@...>

Hi,

19 messages 2007/09/18
[#269601] Re: finding string matches, in order, in a file — William James <w_a_x_man@...> 2007/09/18

[#269605] Re: finding string matches, in order, in a file — Peter Bailey <pbailey@...> 2007/09/18

William James wrote:

[#269627] Re: finding string matches, in order, in a file — William James <w_a_x_man@...> 2007/09/18

On Sep 18, 8:28 am, Peter Bailey <pbai...@bna.com> wrote:

[#269631] Re: finding string matches, in order, in a file — Peter Bailey <pbailey@...> 2007/09/18

William James wrote:

[#269637] Re: finding string matches, in order, in a file — William James <w_a_x_man@...> 2007/09/18

On Sep 18, 10:27 am, Peter Bailey <pbai...@bna.com> wrote:

[#269616] CPU Usage not near 100% when running code — SpringFlowers AutumnMoon <summercoolness@...>

I tested some computation intensive Ruby code. When running, the CPU

11 messages 2007/09/18

[#269732] How to print FULL stacktrace of exception w/ line #? — Andrew Chen <meihome@...>

The ruby interpreter prints out a full trace of the exception.

12 messages 2007/09/19

[#269779] how can I remove all the comments in my c program. — Vellingiri Arul <hariharan.spc@...>

Dear Friends,

25 messages 2007/09/19

[#269813] YAML & readlines & modify text files — Dan George <endege@...>

Hello,

16 messages 2007/09/19
[#269834] Re: YAML & readlines & modify text files — Stefano Crocco <stefano.crocco@...> 2007/09/19

Alle mercoled19 settembre 2007, Dan George ha scritto:

[#269879] Re: YAML & readlines & modify text files — Dan George <endege@...> 2007/09/19

On Sep 19, 5:27 pm, Stefano Crocco <stefano.cro...@alice.it> wrote:

[#269888] Re: YAML & readlines & modify text files — Stefano Crocco <stefano.crocco@...> 2007/09/19

Alle mercoled19 settembre 2007, Dan George ha scritto:

[#269910] Re: YAML & readlines & modify text files — Dan George <endege@...> 2007/09/19

On Sep 19, 9:22 pm, Stefano Crocco <stefano.cro...@alice.it> wrote:

[#269913] Re: YAML & readlines & modify text files — Stefano Crocco <stefano.crocco@...> 2007/09/19

Alle mercoled19 settembre 2007, Dan George ha scritto:

[#269925] Re: YAML & readlines & modify text files — Dan George <endege@...> 2007/09/19

On Sep 19, 11:03 pm, Stefano Crocco <stefano.cro...@alice.it> wrote:

[#269816] How to compute Sunrise / Sunset ? — Joe Joe <joepetrini@...>

I need to compute sunrise/set times in ruby for a given long lat. Does

12 messages 2007/09/19

[#269862] special Array method about Unix pathes — unbewusst.sein@... (Une B騅ue)

15 messages 2007/09/19

[#269873] scraping web pages for cisco products — Chuck Dawit <chuckdawit@...>

16 messages 2007/09/19

[#269902] Do C Extensions Block Ruby? — "Wayne E. Seguin" <wayneeseguin@...>

Does a C extension running in a ruby-thread block all ruby threads

16 messages 2007/09/19
[#269904] Re: Do C Extensions Block Ruby? — Nobuyoshi Nakada <nobu@...> 2007/09/19

Hi,

[#269924] Re: Do C Extensions Block Ruby? — Joel VanderWerf <vjoel@...> 2007/09/19

Nobuyoshi Nakada wrote:

[#269971] Is there any separate editor for ruby? — Vellingiri Arul <hariharan.spc@...>

Hai Friends,

13 messages 2007/09/20

[#270018] Idiomatic Ruby for Array#extract / Range#length? — "Sammy Larbi" <sam@...>

During the monthly meeting of our code dojo, we were surprised by a couple

27 messages 2007/09/20
[#270039] Re: Idiomatic Ruby for Array#extract / Range#length? — Xavier Noria <fxn@...> 2007/09/20

On Sep 20, 2007, at 2:28 PM, Sammy Larbi wrote:

[#270047] Re: Idiomatic Ruby for Array#extract / Range#length? — "Rick DeNatale" <rick.denatale@...> 2007/09/20

On 9/20/07, Xavier Noria <fxn@hashref.com> wrote:

[#270051] Re: Idiomatic Ruby for Array#extract / Range#length? — Xavier Noria <fxn@...> 2007/09/20

On Sep 20, 2007, at 5:39 PM, Rick DeNatale wrote:

[#270056] Re: Idiomatic Ruby for Array#extract / Range#length? — "Rick DeNatale" <rick.denatale@...> 2007/09/20

On 9/20/07, Xavier Noria <fxn@hashref.com> wrote:

[#270065] Re: Idiomatic Ruby for Array#extract / Range#length? — "Rick DeNatale" <rick.denatale@...> 2007/09/20

On 9/20/07, Rick DeNatale <rick.denatale@gmail.com> wrote:

[#270084] Re: Idiomatic Ruby for Array#extract / Range#length? — Xavier Noria <fxn@...> 2007/09/20

On Sep 20, 2007, at 7:26 PM, Rick DeNatale wrote:

[#270110] I am new to Ruby and I could use some expert advice as to how I can make this code run faster. — Ruby Maniac <raychorn@...>

I am new to Ruby and I could use some expert advice as to how I can

62 messages 2007/09/20
[#270145] Re: I am new to Ruby and I could use some expert advice as to how I can make this code run faster. — Brian Adkins <lojicdotcom@...> 2007/09/21

On Sep 20, 6:02 pm, Ruby Maniac <raych...@hotmail.com> wrote:

[#270149] Re: I am new to Ruby and I could use some expert advice as to how I can make this code run faster. — John Joyce <dangerwillrobinsondanger@...> 2007/09/21

[#270236] Re: I am new to Ruby and I could use some expert advice as to how I can make this code run faster. — Ruby Maniac <raychorn@...> 2007/09/21

On Sep 20, 7:16 pm, John Joyce <dangerwillrobinsondan...@gmail.com>

[#270239] Re: I am new to Ruby and I could use some expert advice as to how I can make this code run faster. — "Todd Benson" <caduceass@...> 2007/09/21

On 9/21/07, Ruby Maniac <raychorn@hotmail.com> wrote:

[#270305] Re: I am new to Ruby and I could use some expert advice as to how I can make this code run faster. — "Nobuyoshi Nakada" <nobu@...> 2007/09/22

Hi,

[#270575] Re: I am new to Ruby and I could use some expert advice as to how I can make this code run faster. — "Ilmari Heikkinen" <ilmari.heikkinen@...> 2007/09/24

On 9/22/07, Nobuyoshi Nakada <nobu@ruby-lang.org> wrote:

[#270115] How fast does your Ruby run? — SpringFlowers AutumnMoon <summercoolness@...>

How fast does your Ruby run?

114 messages 2007/09/20
[#270118] Re: How fast does your Ruby run? — Todd Burch <promos@...> 2007/09/20

SpringFlowers AutumnMoon wrote:

[#270167] Re: How fast does your Ruby run? — Charles Oliver Nutter <charles.nutter@...> 2007/09/21

Todd Burch wrote:

[#270168] Re: How fast does your Ruby run? — Charles Oliver Nutter <charles.nutter@...> 2007/09/21

Charles Oliver Nutter wrote:

[#270182] Re: How fast does your Ruby run? — gga <GGarramuno@...> 2007/09/21

Seems like a pretty silly test, but okay...

[#270468] Re: How fast does your Ruby run? — David Orriss Jr <codethought@...> 2007/09/23

SpringFlowers AutumnMoon wrote:

[#276142] Re: How fast does your Ruby run? — Daniel Schömer <daniel.schoemer@...> 2007/10/27

Gentoo Linux on Intel Pentium 4 2.40GHz (512 KB cache):

[#276152] Re: How fast does your Ruby run? — Charles Oliver Nutter <charles.nutter@...> 2007/10/27

Daniel Scher wrote:

[#276153] Re: How fast does your Ruby run? — "M. Edward (Ed) Borasky" <znmeb@...> 2007/10/27

Charles Oliver Nutter wrote:

[#276191] Re: How fast does your Ruby run? — Charles Oliver Nutter <charles.nutter@...> 2007/10/27

M. Edward (Ed) Borasky wrote:

[#270161] Re: [ANN] Metadata 1.0-rc2 — Peña, Botp <botp@...>

From: Ilmari Heikkinen [mailto:ilmari.heikkinen@gmail.com]

6 messages 2007/09/21

[#270245] CplusRuby - Gluing C and Ruby — Michael Neumann <mneumann@...>

Hi all,

22 messages 2007/09/21

[#270320] sequel problem: no such file to load -- mysql (LoadError) — Michael Andreasen <ventosus@...>

Hi, i tried to learn about sequel (and Ruby) and got this problem

10 messages 2007/09/22

[#270377] Getting started with Ruby (noob confusion) — Nunya Business <sasnso4a5w12kb8@...>

Hi everyone!

16 messages 2007/09/22

[#270451] Recent Criticism about Ruby (Scalability, etc.) — "forrie@..." <forrie@...>

I presume most people here read today's article on Slashdot which had

80 messages 2007/09/23
[#270729] Re: Recent Criticism about Ruby (Scalability, etc.) — "Phlip" <phlip2005@...> 2007/09/25

> I presume most people here read today's article on Slashdot

[#270760] Re: Recent Criticism about Ruby (Scalability, etc.) — Chad Perrin <perrin@...> 2007/09/25

On Tue, Sep 25, 2007 at 01:04:21PM +0900, Phlip wrote:

[#270789] Re: Recent Criticism about Ruby (Scalability, etc.) — Ruby Maniac <rubymaniac@...> 2007/09/25

On Sep 25, 1:15 am, Chad Perrin <per...@apotheon.com> wrote:

[#271162] Re: Recent Criticism about Ruby (Scalability, etc.) — Chad Perrin <perrin@...> 2007/09/26

On Tue, Sep 25, 2007 at 10:40:04PM +0900, Ruby Maniac wrote:

[#272380] Re: Recent Criticism about Ruby (Scalability, etc.) — Charles Oliver Nutter <charles.nutter@...> 2007/10/03

Chad Perrin wrote:

[#272394] Re: Recent Criticism about Ruby (Scalability, etc.) — "M. Edward (Ed) Borasky" <znmeb@...> 2007/10/03

Charles Oliver Nutter wrote:

[#272398] Re: Recent Criticism about Ruby (Scalability, etc.) — benjohn@... 2007/10/03

[#272405] Re: Recent Criticism about Ruby (Scalability, etc.) — MenTaLguY <mental@...> 2007/10/03

On Thu, 4 Oct 2007 00:19:40 +0900, benjohn@fysh.org wrote:

[#272412] Re: Recent Criticism about Ruby (Scalability, etc.) — Chad Perrin <perrin@...> 2007/10/03

On Thu, Oct 04, 2007 at 12:38:25AM +0900, MenTaLguY wrote:

[#272426] Re: Recent Criticism about Ruby (Scalability, etc.) — MenTaLguY <mental@...> 2007/10/03

On Thu, 4 Oct 2007 01:42:22 +0900, Chad Perrin <perrin@apotheon.com> wrote:

[#272439] Re: Recent Criticism about Ruby (Scalability, etc.) — Chad Perrin <perrin@...> 2007/10/03

On Thu, Oct 04, 2007 at 02:39:28AM +0900, MenTaLguY wrote:

[#270924] Re: Recent Criticism about Ruby (Scalability, etc.) — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/26

Chad Perrin wrote:

[#270482] how to use Ruby / Tk to display a text message status box — SpringFlowers AutumnMoon <summercoolness@...>

how can we pop up a Tk window to display the temporary results of a

17 messages 2007/09/23
[#270980] Re: how to use Ruby / Tk to display a text message status box — Summercool <Summercoolness@...> 2007/09/26

[#270508] This is why Ruby 1.8.6 can never be made to run anywhere near as fast as Python 2.5.1 — Ruby Maniac <raychorn@...>

I welcome any corrections anyone might be able to make since I am new

60 messages 2007/09/24
[#270524] Re: This is why Ruby 1.8.6 can never be made to run anywhere near as fast as Python 2.5.1 — Phrogz <phrogz@...> 2007/09/24

On Sep 23, 8:50 pm, Ruby Maniac <raych...@hotmail.com> wrote:

[#270531] Re: This is why Ruby 1.8.6 can never be made to run anywhere near as fast as Python 2.5.1 — John Joyce <dangerwillrobinsondanger@...> 2007/09/24

Why do people troll?

[#270535] Re: This is why Ruby 1.8.6 can never be made to run anywhere near as fast as Python 2.5.1 — Mohit Sindhwani <mo_mail@...> 2007/09/24

John Joyce wrote:

[#270557] Re: This is why Ruby 1.8.6 can never be made to run anywhere near as fast as Python 2.5.1 — benjohn@... 2007/09/24

> John Joyce wrote:

[#270597] Re: This is why Ruby 1.8.6 can never be made to run anywhere near as fast as Python 2.5.1 — Chad Perrin <perrin@...> 2007/09/24

On Mon, Sep 24, 2007 at 06:34:57PM +0900, benjohn@fysh.org wrote:

[#270599] Re: This is why Ruby 1.8.6 can never be made to run anywhere near as fast as Python 2.5.1 — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/24

Chad Perrin wrote:

[#270727] Re: This is why Ruby 1.8.6 can never be made to run anywhere — 7stud -- <dolgun@...> 2007/09/25

Bill Kelly wrote:

[#270532] Re: This is why Ruby 1.8.6 can never be made to run anywhere near as fast as Python 2.5.1 — "Michael T. Richter" <ttmrichter@...> 2007/09/24

Can I ask why *ANYBODY* took a message by someone calling themselves

[#270536] Re: This is why Ruby 1.8.6 can never be made to run anywhere near as fast as Python 2.5.1 — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/24

Michael T. Richter wrote:

[#270542] "myscript.rb " - there's a blank in my name! — Todd Burch <promos@...>

On a Mac - Tiger 10.4.10.

13 messages 2007/09/24

[#270596] best way to 'hide' a method when method_missing is in town — "Kevin Barnes" <vinbarnes@...>

I am trying to hide a method in a subclass whose base class has

11 messages 2007/09/24

[#270663] Favorite idiom for "keep doing this until it returns nil/false" — Phrogz <phrogz@...>

I want to keep running gsub! on a string until it returns nil. How do

12 messages 2007/09/24

[#270708] object_id 1, 2, 3 — SpringFlowers AutumnMoon <summercoolness@...>

Fixnum object_id

15 messages 2007/09/25

[#270788] I love Ruby but what is the deal with... this ! — Ruby Maniac <rubymaniac@...>

I love Ruby but what is the deal with the lack of a VM ?

25 messages 2007/09/25
[#270791] Re: I love Ruby but what is the deal with... this ! — Gregory Seidman <gsslist+ruby@...> 2007/09/25

On Tue, Sep 25, 2007 at 10:35:06PM +0900, Ruby Maniac wrote:

[#270794] Re: I love Ruby but what is the deal with... this ! — Ruby Maniac <rubymaniac@...> 2007/09/25

On Sep 25, 6:52 am, Gregory Seidman <gsslist+r...@anthropohedron.net>

[#270815] Re: I love Ruby but what is the deal with... this ! — "Walter Purvis" <wpmailinglists@...> 2007/09/25

Troll.

[#270867] Re: I love Ruby but what is the deal with... this ! — Ruby Maniac <rubymaniac@...> 2007/09/25

On Sep 25, 8:23 am, "Walter Purvis" <wpmailingli...@gmail.com> wrote:

[#270872] Re: I love Ruby but what is the deal with... this ! — Phlip <phlip2005@...> 2007/09/25

> Do you classify all those who have an opposing viewpoint as being a

[#270792] Ruby Scales just fine ! — Ruby Maniac <rubymaniac@...>

Just buy a bunch of Quad Core Opterons and get over it !

24 messages 2007/09/25
[#270800] Re: Ruby Scales just fine ! — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/25

Ruby Maniac wrote:

[#270842] Re: Ruby Scales just fine ! — Eric Hodel <drbrain@...7.net> 2007/09/25

On Sep 25, 2007, at 07:22 , M. Edward (Ed) Borasky wrote:

[#270813] Why dynamic languages for ActiveRecord..? — ypomonh <ypomonh@...>

I having problems understanding why people prefer to implement the

14 messages 2007/09/25

[#270888] The guy who wrote RubyScript2Exe needs to seriously reconsider how this little "gem" works... — Ruby Maniac <rubymaniac@...>

I have a very simple Ruby script that does nothing more than compute

13 messages 2007/09/25

[#270916] ruby regex on html file — eggie5 <eggie5@...>

I'm trying to write a rake task to extract all the script tags out of

12 messages 2007/09/25

[#270966] Feature request for RubyScript2Exe — Ruby Maniac <rubymaniac@...>

It would be nice if RubyScript2Exe was able to handle a passworded ZIP

11 messages 2007/09/26

[#270989] Detecting number ranges — Jay Levitt <jay+news@...>

I had to write a script this evening to take an unsorted input file of the

17 messages 2007/09/26

[#271046] Finding the last Sunday of a month — Peter Bailey <pbailey@...>

Hello,

31 messages 2007/09/26
[#271050] Re: Finding the last Sunday of a month — Yossef Mendelssohn <ymendel@...> 2007/09/26

On Sep 26, 8:44 am, Peter Bailey <pbai...@bna.com> wrote:

[#271078] Recursing through directories — Gabriel Dragffy <gabe@...>

Hi there

14 messages 2007/09/26

[#271089] OneClickInstaller/RubyGems problems — Trans <transfire@...>

Is there anything you have to do after installing the Windows

16 messages 2007/09/26

[#271143] Confession: I never learned CS — Jay Levitt <jay+news@...>

I was thinking about my "Detecting number ranges" question and the various

24 messages 2007/09/26
[#271317] Re: Confession: I never learned CS — Jay Levitt <jay+news@...> 2007/09/27

On Thu, 27 Sep 2007 23:57:08 +0900, Ilmari Heikkinen wrote:

[#271147] Syntax for <stringVariable>.new ? — Larry Fast <lfast@...>

Hi Rubyists and ...istas,

14 messages 2007/09/26
[#271148] Re: Syntax for <stringVariable>.new ? — Sebastian Hungerecker <sepp2k@...> 2007/09/26

Larry Fast wrote:

[#271212] Confession: I never did ASM — julik <listbox@...>

I would love to join the recently started confession fest.

57 messages 2007/09/27
[#271220] Re: [OT] Confession: I never did ASM — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/27

julik wrote:

[#271279] Re: [OT] Confession: I never did ASM — John Joyce <dangerwillrobinsondanger@...> 2007/09/27

[#271393] Re: [OT] Confession: I never did ASM — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/28

John Joyce wrote:

[#271403] Re: [OT] Confession: I never did ASM — John Joyce <dangerwillrobinsondanger@...> 2007/09/28

[#271412] Re: [OT] Confession: I never did ASM — "M. Edward (Ed) Borasky" <znmeb@...> 2007/09/28

John Joyce wrote:

[#271672] Re: Confession: I never did ASM — Brian Adkins <lojicdotcom@...> 2007/09/29

On Sep 27, 1:21 am, julik <list...@julik.nl> wrote:

[#271695] Re: Confession: I never did ASM — John Joyce <dangerwillrobinsondanger@...> 2007/09/29

[#272303] Re: Confession: I never did ASM — Brian Adkins <lojicdotcom@...> 2007/10/03

On Sep 29, 3:27 pm, John Joyce <dangerwillrobinsondan...@gmail.com>

[#272307] Re: Confession: I never did ASM — John Joyce <dangerwillrobinsondanger@...> 2007/10/03

[#272309] Re: Confession: I never did ASM — "M. Edward (Ed) Borasky" <znmeb@...> 2007/10/03

John Joyce wrote:

[#272322] Re: Confession: I never did ASM — John Joyce <dangerwillrobinsondanger@...> 2007/10/03

[#272325] Re: Confession: I never did ASM — "M. Edward (Ed) Borasky" <znmeb@...> 2007/10/03

John Joyce wrote:

[#272423] Re: Confession: I never did ASM — Chad Perrin <perrin@...> 2007/10/03

On Wed, Oct 03, 2007 at 02:08:02PM +0900, M. Edward (Ed) Borasky wrote:

[#272508] Re: Confession: I never did ASM — "M. Edward (Ed) Borasky" <znmeb@...> 2007/10/04

Chad Perrin wrote:

[#271356] is there to invoke 'previous' in Find? (or refresh the current path?) — "dtown22@..." <dtown22@...>

I am writing a small script which recursively goes down a dir

10 messages 2007/09/27

[#271360] mac - hpricot problems — Sergio Ruiz <sergio@...>

i am trying to get hpricot running (so i can run mechanize) and am

24 messages 2007/09/27
[#271368] Re: mac - hpricot problems — Daniel Waite <rabbitblue@...> 2007/09/27

Sergio Ruiz wrote:

[#271370] Re: mac - hpricot problems — Sergio Ruiz <sergio@...> 2007/09/28

[#271376] Re: mac - hpricot problems — Ryan Davis <ryand-ruby@...> 2007/09/28

[#271364] Re: Anyone interested In IronRuby — Phrogz <phrogz@...>

On Sep 26, 11:47 pm, IronRuby <rubyguja...@gmail.com> wrote:

12 messages 2007/09/27

[#271394] dike-0.0.1 - a memory leak detector — "ara.t.howard" <ara.t.howard@...>

19 messages 2007/09/28
[#271522] Re: [ANN] dike-0.0.1 - a memory leak detector — Joel VanderWerf <vjoel@...> 2007/09/28

ara.t.howard wrote:

[#271526] Re: [ANN] dike-0.0.1 - a memory leak detector — "ara.t.howard" <ara.t.howard@...> 2007/09/28

[#271467] Probable Iterations (#141) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

15 messages 2007/09/28

[#271472] Windows - Get current logged user — Rodrigo Bermejo <rodrigo.bermejo@...>

14 messages 2007/09/28

[#271499] a different type of reference (shocked) — SpringFlowers AutumnMoon <summercoolness@...>

Before, when I say Ruby's reference to an object

14 messages 2007/09/28

[#271617] how can I start a shell process and return immediately? — Stephen Bannasch <stephen.bannasch@...>

I want to start a Java program from a Ruby program and have the Java

16 messages 2007/09/29
[#341070] Re: how can I start a shell process and return immediately? — Enling Li <enling.li@...> 2009/07/09

I have another quetion related to fire off a back ground shell process

[#271649] Is there a combination of a struct and an array? I wanna iterate over all created objects from a certain struct-class (I guess). — kazaam <kazaam@...>

I have a file with many entries and much of these I don't need. Let's imagine:

8 messages 2007/09/29

[#271673] a = Dog.new # a is not a pointer and not a reference? — SpringFlowers AutumnMoon <summercoolness@...>

when we say

57 messages 2007/09/29
[#271677] Re: a = Dog.new # a is not a pointer and not a reference? — Morton Goldberg <m_goldberg@...> 2007/09/29

On Sep 29, 2007, at 1:16 PM, SpringFlowers AutumnMoon wrote:

[#271698] Re: a = Dog.new # a is not a pointer and not a reference? — "Austin Ziegler" <halostatue@...> 2007/09/29

On 9/29/07, Morton Goldberg <m_goldberg@ameritech.net> wrote:

[#271718] Re: a = Dog.new # a is not a pointer and not a reference? — Joel VanderWerf <vjoel@...> 2007/09/29

Austin Ziegler wrote:

[#271804] Re: a = Dog.new # a is not a pointer and not a reference? — "Austin Ziegler" <halostatue@...> 2007/09/30

On 9/29/07, Joel VanderWerf <vjoel@path.berkeley.edu> wrote:

[#271732] Re: a = Dog.new # a is not a pointer and not a reference? — SpringFlowers AutumnMoon <summercoolness@...> 2007/09/30

Austin Ziegler wrote:

[#271734] Re: a = Dog.new # a is not a pointer and not a reference? — SpringFlowers AutumnMoon <summercoolness@...> 2007/09/30

SpringFlowers AutumnMoon wrote:

[#271740] Re: a = Dog.new # a is not a pointer and not a reference? — Morton Goldberg <m_goldberg@...> 2007/09/30

On Sep 29, 2007, at 8:18 PM, SpringFlowers AutumnMoon wrote:

[#271738] Newbie needs help getting user input — Peter Vanderhaden <bostonantifan@...>

I'm trying to learn Ruby and trying to convert a Perl program at the

14 messages 2007/09/30

[#271776] Can you please help to make decision? — Byung-Hee HWANG <bh@...>

Fist of all, sorry for poor English, I am not professional English

34 messages 2007/09/30
[#271808] Re: Can you please help to make decision? — 7stud -- <dolgun@...> 2007/09/30

I would choose python.

[#271784] which language allows you to change an argument's value? — Summercool <Summercoolness@...>

34 messages 2007/09/30

Re: Newbie help

From: 7stud -- <dolgun@...>
Date: 2007-09-16 08:20:38 UTC
List: ruby-talk #269232
Hi,

Ali Koubeissi wrote:
> Hey, I've started with Ruby two days ago, and I have some questions.
> 
> 1- What's the use of Symbols? I've read that symbols are (Symbols are
> lightweight strings. Usually, symbols are used in situations where you
> need a string but you won’t be printing it to the screen.), however I
> cannot understand how to use them, and so I tried to read some examples
> and I got this:
> 
> kitty_toys =
>    [:shape => 'sock', :fabric => 'cashmere'] +
>    [:shape => 'mouse', :fabric => 'calico'] +
>    [:shape => 'eggroll', :fabric => 'chenille']
> kitty_toys.sort_by { |toy| toy[:fabric] }
> 
> Why is he using symbols? I just couldn't understand ;(.

It might save memory and make the program run faster.

I'm also new to Ruby, so I'll post my understanding of symbols so 
far--at the very least it should provide the experts with some easy 
weekend target practice.  If you search on google, you'll find that 
explaining symbols has been hotly debated in the past, so I am under no 
illusion that this is the correct or only interpretation.

> 1- What's the use of Symbols? I've read that symbols are (Symbols are
> lightweight strings. Usually, symbols are used in situations where you
> need a string but you won’t be printing it to the screen.), however I
> cannot understand how to use them, and so I tried to read some examples
> and I got this:
> 
> kitty_toys =
>    [:shape => 'sock', :fabric => 'cashmere'] +
>    [:shape => 'mouse', :fabric => 'calico'] +
>    [:shape => 'eggroll', :fabric => 'chenille']
> kitty_toys.sort_by { |toy| toy[:fabric] }
> 
> Why is he using symbols? I just couldn't understand ;(.

In java, if you write:

String s1 = "hello world";
String s2 = "hello";
String s3 = "world";
s2 += s3;

if(s1 == s2)
{
  System.out.println("yes");
}
else
{
  System.out.println("no");
}

the output will be 'no'.  Why?  Because in java, the == operator tests 
whether two objects are the same object--not whether their values are 
identical. However, if you write this:

String s1 = "hello";
String s2 = "hello";

if(s1 == s2)    //checks whether s1 and s2 refer to the same string 
object
{
  System.out.println("yes");
}

the output will be 'yes'.  Java does not create a second string object 
when you assign a string literal that already exists in memory to 
another String variable.  Instead, both String variables will refer to 
the same String object.  That saves memory and can speed up execution.

On the other hand, Ruby creates new string objects for every string 
literal that you assign to a variable:

s1 = "hello"
s2 = "hello"

puts s1.object_id
puts s2.object_id

--output:--
76810
76800

Note that in ruby you have to look at the object id's to determine 
whether two objects are the same, because in ruby the == operator 
compares the values of two string objects--not the string objects 
themselves.  That's different than the way Java's == operator works. 
The == operator in ruby is equivalent to the equals() method in java.

Since ruby does the opposite with duplicate strings as Java, the 
opposite conclusion might be true: ruby's string handling hogs memory 
and slows down execution.

Enter symbols:

s1 = :hello
s2 = :hello
s3 = :hello

puts s1.object_id
puts s2.object_id
puts s3.object_id

--output:--
2545934
2545934
2545934

puts s1.to_s
puts s2.to_s
puts s3.to_s

--output:--
hello
hello
hello

I think this is what it looks like:


    "hello"
       ^
       |
       |
   symbol_obj
   id:2545934
   ^   ^   ^
   |   |   |
   s1  s2  s3


I found the description here helpful:

http://moonbase.rydia.net/mental/blog/programming/ruby-symbols-explained

-----
For every unique string value, there is a unique symbol object.

Testing two symbol values for equality (or non-equality) is faster than 
testing two string values for equality, because Ruby only needs to do a 
single test[ruby compares the symbol id's]. Checking two strings for 
equality is more complicated; every individual character in the string 
has to be checked until a difference is found.

As noted above, each unique string value has an associated symbol. This 
means that checking whether two symbols have the same string value or 
not is as simple as checking whether they are the same object or not.

One comparison:

:Worcestershire == :Worcestershire
Easy peasy. They’re the same object, so they’re equal.

Sixteen comparisons:

"Worcestershire" == "Worcestershire"

With strings, Ruby has to dig into the objects to check their contents. 
Since in this case they’re different string objects with the same 
length, it’s got to check all fourteen characters in each string to make 
sure that they really are equal.
-----

Finally, remember that symbols are not string objects, so string methods 
do not work on symbols:

s1 = "hello"
s1.upcase!
puts s1

--output:--
HELLO

s2 = :hello
s2.upcase!
puts s2

--output:--
undefined method `upcase!' for :hello:Symbol (NoMethodError)

However, you can always get the string that a symbol refers to and call 
string functions on the string:

s2 = :hello
s3 = s2.to_s
s3.upcase!

puts s3

--output:--
HELLO

For a final twist, there is method called send(), which is a method of 
Object.  send() takes an argument that is a symbol.  The symbol argument 
should refer to a string, and that string should be the name of a 
method.  send() then executes the method:

def show(x)
    puts x
end

send(:show, 10)

The method name 'send' comports with the ruby terminology that you are 
sending messages to objects when you write something like:

my_string.upcase!

In ruby, that code is described as sending the upcase! message to the 
the object my_string, which causes the upcase! method in the string 
class to execute.

All languages I've studied have a way to call a method when you have the 
method name as a string, e.g. the user entered a method name and you 
need to call that method.  In Java, you do that with reflection and a 
few contortions.  Because a symbol refers to a string, it's not much of 
a stretch to think that you should be able to execute a function when 
you have a symbol: the symbol can be used to get the string.  In fact, 
it appears that send() will also accept a string as an argument, 
although that isn't documented:

def show(x)
    puts x
end

send("show", 10)


Knowing when to use symbols to optimize your code will hopefully come 
with experience.  See these articles as well,

The Ruby_Newbie Guide to Symbols:
http://www.troubleshooters.com/codecorn/ruby/symbols.htm

13 ways to look at a Ruby symbol:
http://www.randomhacks.net/articles/2007/01/20/13-ways-of-looking-at-a-ruby-symbol


> 2- Why does a block has to be on the same line when passing argument?
> Like in the previous example: kitty_toys.sort_by { |toy| toy[:fabric] }.
> If I tried to move the block down, it won't work. 

The file that contains your program is just a text file.  ruby has to 
interpret the text in the file and make sense of it.  In order for ruby 
to make sense of the text, you have to follow certain syntax rules. 
Apparently, a syntax rule in ruby is that a brace enclosed block has to 
be on the same line as the method call so that ruby knows it is 
associated with the method call.  Of course, you can always use the "do" 
form for lengthy blocks:


kitty_toys.sort_by do |toy|
     toy[:fabric]

     #200 lines of other code here

end

> Also, if someone could
> explain how does the argument get passed to the block. I mean, based on
> what?

You can think of a block as a second method.  The first method specified 
before the block, e.g. sort_by in your example, calls the second 
method(the block).  However, only a method that is written to call a 
second method can have a block.  Methods that call a second method(the 
block) need to be defined with a yield statement(or the equivalent). 
Here is an example of a method I made up that can call another method 
that is a block:

def func
    arr = [3, 6, 9, 12]
    count = 0

    while count <= 3
        yield arr[count]
        count += 1
    end

end

In fact, calling that method without a block will produce an error.  A 
yield statement is similar to a normal method call: the yield statement 
sends the value specified after 'yield' to the block, e.g arr[count] in 
func.  The yielded value then gets assigned to the block parameter 
variable.  Subsequently, the block can do whatever it wants with the 
value.  Execution in func halts at the point of the yield statement 
until the block finishes executing, at which point execution continues 
in the func.  Since func has a repeating while loop, the block is called 
repeatedly with different values.  Here is an example of calling func 
with a block:


def func
    arr = [3, 6, 9, 12]
    count = 0

    while count <= 3
        yield arr[count]
        count += 1
    end

end


func {|i| puts i * 2}

--output:--
6
12
18
24



Here is another example:

def func
    yield
    yield
    yield
end


func {puts "hello"}

Since func doesn't yield any values(there are no values specified after 
the word 'yield'), the block doesn't need to be defined with a parameter 
variable to catch the values.  In fact, you can't define a block with a 
parameter variable if no values are going to be sent to the 
block--you'll get an error that says the block was expecting one 
argument and got zero.

If it helps you to understand, you can also do the equivalent(nearly) 
using a Proc object.  A Proc object represents a method.  Proc objects 
allow you to explicitly send methods as arguments to other methods, 
rather than doing so implicitly with a block:

def func(proc_obj)
    arr = [3, 6, 9, 12]
    count = 0

    while count <= 3
        proc_obj.call(arr[count])
        count += 1
    end
end

p = Proc.new {|i| puts i * 2}
func(p)

--output:--
6
12
18
24


> 3- How does a Ruby file compile? Like in Java, your code gets compiled
> into bytecode, and then delivered to the JVM. Are there any similarities
> in Ruby?

Uhmmm...I don't think that's quite the way it works in java.  In java, 
you compile your program into byte code *before* executing it.  Byte 
code consists of instructions for the java jvm.  After compiling, you 
execute your program, which sends the byte code instructions to your 
platform specific jvm installed on your computer.  The jvm then converts 
the byte code into machine instructions that your specific os can 
understand.

I'm not quite sure about the nitty gritty details in Ruby, but when you 
execute a Ruby program, full compilation is done before execution can 
begin.  From what I've read, Ruby is much slower than Java, and it's 
also slower than just about any other comparable language, e.g Perl, 
Python, PHP, etc. It's significantly slower than Java because it has to 
do a full compilation before executing the code, and Ruby is a 
dynamically typed language(i.e. variables don't have types and can be 
assigned any type).  Dynamically typed languages cannot be optimized as 
much as statically typed languages like Java.


> I'm currently reading Programming Ruby 2nd Edition, 

Me too.  :)
-- 
Posted via http://www.ruby-forum.com/.

In This Thread