[#262740] Any experience with Bluehost? — joviyach <joviyach@...>

I am looking for hosting for RoR, but I'd also like to be able to do

15 messages 2007/08/01
[#262768] Re: Any experience with Bluehost? — Brett Simmers <bsimmers@...> 2007/08/01

joviyach wrote:

[#262749] Railless ActiveRecord — Ari Brown <ari@...>

Hey all. More ActiveRecord trouble.

16 messages 2007/08/01

[#262782] Dynamic method call — "Andrea Maschio" <andrea.maschio@...>

I'm trying, for the purpose of making something similar to a grammar, to do

32 messages 2007/08/01
[#262785] Re: Dynamic method call — Sharon Phillips <phillipsds@...> 2007/08/01

> I'm trying, for the purpose of making something similar to a

[#262791] Re: Dynamic method call — "Andrea Maschio" <andrea.maschio@...> 2007/08/01

Thank you very much guys, it worked. I was doing this for the purpose of

[#262827] Re: Dynamic method call — "Gregory Brown" <gregory.t.brown@...> 2007/08/01

On 8/1/07, Andrea Maschio <andrea.maschio@gmail.com> wrote:

[#262882] Re: Dynamic method call — "Andrea Maschio" <andrea.maschio@...> 2007/08/01

the problem is that method_name is a static call, i need to make it dynamic

[#262883] Re: Dynamic method call — "Gregory Brown" <gregory.t.brown@...> 2007/08/01

On 8/1/07, Andrea Maschio <andrea.maschio@gmail.com> wrote:

[#262904] Private methods not so private? — Frank Meyer <lolz.llolz@...>

Hello,

15 messages 2007/08/01

[#263011] Beginner's tutorial and poor attempt at classes — Gabriel Dragffy <gabe@...>

Hi all

16 messages 2007/08/02
[#263012] Re: Beginner's tutorial and poor attempt at classes — dblack@... 2007/08/02

Hi --

[#263034] #send in 1.9 — Trans <transfire@...>

Looking over 1.9's change of #send, ie.

61 messages 2007/08/02
[#263036] Re: #send in 1.9 — "Tim Pease" <tim.pease@...> 2007/08/02

On 8/2/07, Trans <transfire@gmail.com> wrote:

[#263093] Re: #send in 1.9 — Ari Brown <ari@...> 2007/08/02

[#263672] Re: #send in 1.9 — Trans <transfire@...> 2007/08/07

[#263674] Re: #send in 1.9 — "Gregory Brown" <gregory.t.brown@...> 2007/08/07

On 8/7/07, Trans <transfire@gmail.com> wrote:

[#263684] Re: #send in 1.9 — Trans <transfire@...> 2007/08/07

[#263687] Re: #send in 1.9 — "Gregory Brown" <gregory.t.brown@...> 2007/08/07

On 8/7/07, Trans <transfire@gmail.com> wrote:

[#263736] Re: #send in 1.9 — Trans <transfire@...> 2007/08/07

[#263747] Re: #send in 1.9 — "Gregory Brown" <gregory.t.brown@...> 2007/08/08

On 8/7/07, Trans <transfire@gmail.com> wrote:

[#263781] Re: #send in 1.9 — dblack@... 2007/08/08

Hi --

[#263825] Re: #send in 1.9 — Trans <transfire@...> 2007/08/08

[#263837] Re: #send in 1.9 — James Edward Gray II <james@...> 2007/08/08

On Aug 8, 2007, at 9:52 AM, Trans wrote:

[#263841] Re: #send in 1.9 — "Robert Dober" <robert.dober@...> 2007/08/08

On 8/8/07, James Edward Gray II <james@grayproductions.net> wrote:

[#263845] Re: #send in 1.9 — James Edward Gray II <james@...> 2007/08/08

On Aug 8, 2007, at 10:30 AM, Robert Dober wrote:

[#263115] Determining the common prefix for several strings — Todd Burch <promos@...>

I have several strings to analyze. The strings are the names of a list

38 messages 2007/08/03
[#263137] Re: Determining the common prefix for several strings — Xavier Noria <fxn@...> 2007/08/03

El Aug 3, 2007, a las 2:31 AM, Todd Burch escribi鷓

[#263140] Re: Determining the common prefix for several strings — Xavier Noria <fxn@...> 2007/08/03

El Aug 3, 2007, a las 4:26 AM, Xavier Noria escribi鷓

[#263141] Re: Determining the common prefix for several strings — Xavier Noria <fxn@...> 2007/08/03

El Aug 3, 2007, a las 4:41 AM, Xavier Noria escribi鷓

[#263195] Numbers Can Be Words (#133) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

14 messages 2007/08/03

[#263200] Getting the 'Sender' or 'Caller' object of a method — Peter Laurens <peterlaurenspublic@...>

Hi,

12 messages 2007/08/03

[#263250] ruby on the zaurus — "Sy Ali" <sy1234@...>

I'm happy with the older ruby 1.8.4 which I have for my Zaurus

17 messages 2007/08/03
[#263253] Re: ruby on the zaurus — gregarican <greg.kujawa@...> 2007/08/03

On Aug 3, 2:56 pm, "Sy Ali" <sy1...@gmail.com> wrote:

[#263257] Re: ruby on the zaurus — gregarican <greg.kujawa@...> 2007/08/03

On Aug 3, 3:13 pm, gregarican <greg.kuj...@gmail.com> wrote:

[#263303] Better way to do this? Currently using two method_missing calls... — Dan <dan.gottlieb@...>

Hi,

15 messages 2007/08/03
[#263306] Re: Better way to do this? Currently using two method_missing calls... — Xavier Noria <fxn@...> 2007/08/04

El Aug 4, 2007, a las 1:50 AM, Dan escribi鷓

[#263331] Re: Better way to do this? Currently using two method_missing calls... — Dan <dan.gottlieb@...> 2007/08/04

Thanks for the reply. I'm probably being dense here, but I don't see

[#263339] Re: Better way to do this? Currently using two method_missing calls... — Xavier Noria <fxn@...> 2007/08/04

El Aug 4, 2007, a las 1:29 PM, Dan escribi鷓

[#263344] Re: Better way to do this? Currently using two method_missing calls... — Dan <dan.gottlieb@...> 2007/08/04

Ok, I see where you were going now. I guess I could go in that

[#263304] python-style decorators — Keith Rarick <kr@...>

I've been using ruby for about 8 months now and I've come to appreciate

35 messages 2007/08/03
[#263505] Re: python-style decorators — Trans <transfire@...> 2007/08/06

[#263719] Re: python-style decorators — "Keith Rarick" <kr@...> 2007/08/07

On 8/6/07, Trans <transfire@gmail.com> wrote:

[#266555] Re: python-style decorators — Trans <transfire@...> 2007/08/28

[#266763] Re: python-style decorators — Daniel DeLorme <dan-ml@...42.com> 2007/08/29

Trans wrote:

[#266765] Re: python-style decorators — "Keith Rarick" <kr@...> 2007/08/29

On 8/29/07, Daniel DeLorme <dan-ml@dan42.com> wrote:

[#266769] Re: python-style decorators — Trans <transfire@...> 2007/08/30

[#266844] Re: python-style decorators — "Keith Rarick" <kr@...> 2007/08/30

On 8/29/07, Trans <transfire@gmail.com> wrote:

[#266845] Re: python-style decorators — Trans <transfire@...> 2007/08/30

[#266873] Re: python-style decorators — "Keith Rarick" <kr@...> 2007/08/30

On 8/30/07, Trans <transfire@gmail.com> wrote:

[#263347] building rubygems without documentation — "Sy Ali" <sy1234@...>

I see no way to build rubygems without documentation. I checked the

13 messages 2007/08/04
[#263359] Re: building rubygems without documentation — Ben Bleything <ben@...> 2007/08/04

On Sat, Aug 04, 2007, Sy Ali wrote:

[#263480] yield or call? — "Ronald Fischer" <ronald.fischer@...>

def f(&b)

24 messages 2007/08/06
[#263481] Re: yield or call? — "Phlip" <phlip2005@...> 2007/08/06

Ronald Fischer wrote:

[#263586] Alternate Regular Expressions? — Ari Brown <ari@...>

Just randomly curious -

27 messages 2007/08/07
[#263588] Re: Alternate Regular Expressions? — "Phlip" <phlip2005@...> 2007/08/07

Ari Brown wrote:

[#263592] Re: Alternate Regular Expressions? — Ari Brown <ari@...> 2007/08/07

[#263596] Re: Alternate Regular Expressions? — Kenneth McDonald <kenneth.m.mcdonald@...> 2007/08/07

Ari,

[#263602] Re: Alternate Regular Expressions? — Ari Brown <ari@...> 2007/08/07

I'm moderately serious. This is going to be one of those projects

[#263613] I came from Perl, and would ask for some quick start point — Lee NL <ruby@...>

Dear all,

12 messages 2007/08/07

[#263627] Feature request (pretty_inspect variant, yielding single quotes instead of double) — "Ronald Fischer" <ronald.fischer@...>

require 'pp'

8 messages 2007/08/07

[#263688] Need Solaris Help — James Edward Gray II <james@...>

I'm told the following bit of code doesn't work on Solaris:

20 messages 2007/08/07

[#263728] non-constant strings — Dmitry Bilunov <kmeaw@...>

Hello. Why does Ruby have non-constant strings? It seems there is a way

15 messages 2007/08/07

[#263796] case statement — Shai Rosenfeld <shaiguitar@...>

hi guys,

22 messages 2007/08/08

[#263853] deadlock in ThreadPool using backtick — Justin Johnson <justinjohnson@...>

Hello,

19 messages 2007/08/08

[#263930] Collect objects from an array based on one unique parameter — Milo Thurston <knirirr@...>

If one has an array of objects, each containing various values, what

13 messages 2007/08/09
[#263932] Re: Collect objects from an array based on one unique parameter — Konrad Meyer <konrad@...> 2007/08/09

On Thursday 09 August 2007 02:24:46 am Milo Thurston wrote:

[#263989] define_method with default parameters — Emmanuel Oga <oga_emmanuel_oga@...>

how can i use define_method to assign default parameters?

13 messages 2007/08/09

[#264089] Cellular Automata (#134) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

32 messages 2007/08/10

[#264113] Any recommendations on ruby editor — "harry pillei" <Hari@...>

Hi,

31 messages 2007/08/10
[#264122] Re: Any recommendations on ruby editor — franco <flazzarino@...> 2007/08/10

On Aug 10, 12:37 pm, "harry pillei" <H...@pillai.co.uk> wrote:

[#264135] Sorting a logfile, how would you write it? — Frank Meyer <lolz.llolz@...>

I've written a little ruby program which can sort logfiles with the

15 messages 2007/08/10
[#264149] Re: Sorting a logfile, how would you write it? — William James <w_a_x_man@...> 2007/08/10

On Aug 10, 1:29 pm, Frank Meyer <lolz.ll...@gmail.com> wrote:

[#264172] Re: Sorting a logfile, how would you write it? — Ryan Davis <ryand-ruby@...> 2007/08/11

[#264160] Split a string based on change of character — Andrew Savige <ajsavige@...>

For a string "ZBBBCZZ", I want to produce a list ["Z", "BBB", "C", "ZZ"]

27 messages 2007/08/11

[#264193] global_variable_set (like instance_variable_set) — Thomas Hafner <thomas@...>

Hello,

15 messages 2007/08/11

[#264211] Interesting garbage collection article on LTU — Lionel Bouton <lionel-subscription@...>

Hi,

11 messages 2007/08/11

[#264234] launchy 0.1.2 Released — Jeremy Hinegardner <jeremy@...>

launchy version 0.1.2 has been released.

19 messages 2007/08/12
[#264243] Re: launchy 0.1.2 Released — Trans <transfire@...> 2007/08/12

[#264244] Re: launchy 0.1.2 Released — Sebastian Hungerecker <sepp2k@...> 2007/08/12

Trans wrote:

[#264270] Ubuntu as a Ruby dev environment? — joviyach <joviyach@...>

Developing using things like MySQL, PHP, and Ruby has been an absolute

27 messages 2007/08/12

[#264305] Can .rhtml files include text from .txt or .html file? — Sfdesigner Sfdesigner <daniel@...>

Hi,

11 messages 2007/08/12

[#264314] Non Existent Method Dir.empty? Description via "ri" — "Wolfgang Nádasi-donner" <ed.odanow@...>

Moin, moin!

24 messages 2007/08/12
[#264586] Re: Non Existent Method Dir.empty? Description via "ri" — Daniel Berger <djberg96@...> 2007/08/14

[#264598] Re: Non Existent Method Dir.empty? Description via "ri" — "Wolfgang Nádasi-donner" <ed.odanow@...> 2007/08/14

Daniel Berger wrote:

[#264350] TCPSocket Flushing — David -- <neko18@...>

I have two programs, a server and a client. I want to send two messages

13 messages 2007/08/13

[#264445] Why don't Ruby libraries share memory? — "Matt Harvey" <matt@...>

This paragraph is motivation. While my question is not Rails-specific, I am

12 messages 2007/08/13

[#264508] Why is rake really slow? — richpoirier@...

Is rake supposed to be really slow?

13 messages 2007/08/14

[#264532] Does an Array#apply make any sense at all? — "nikolai.weibull@..." <nikolai.weibull@...>

Hi!

29 messages 2007/08/14

[#264783] mp3 file magic number identification — John Joyce <dangerwillrobinsondanger@...>

Does anybody know how to identify (validate) mp3 files (other audio

15 messages 2007/08/15

[#264817] grep a csv? — Michael Linfield <globyy3000@...>

If i had a huge CSV file, and i wanted to pull out say all the lines

27 messages 2007/08/16
[#264821] Re: grep a csv? — "M. Edward (Ed) Borasky" <znmeb@...> 2007/08/16

Michael Linfield wrote:

[#264826] Re: grep a csv? — Michael Linfield <globyy3000@...> 2007/08/16

M. Edward (Ed) Borasky wrote:

[#264911] Double quote escape character — Alvaro Perez <alvaro.pmartinez@...>

Hi all,

13 messages 2007/08/16

[#264923] Does singleton variables have any meaning ? — "Arno J." <jub@...>

Hello,

17 messages 2007/08/16
[#264967] Re: Does singleton variables have any meaning ? — dblack@... 2007/08/16

Hi --

[#265015] Re: Does singleton variables have any meaning ? — "Arno J." <jub@...> 2007/08/16

>> class << self #or class << A

[#265115] wishing of reactive programming in ruby — ashishwave <ashishwave@...>

ruby integrates power of functional programming from lisp , purest OO

17 messages 2007/08/17

[#265130] method access to the enclosing method's locals? — Larry Kluger <rubyforum@...>

18 messages 2007/08/17

[#265154] 8086 simulator in ruby — Vasil Vangelovski <vvangelovski@...>

I'm thinking of writing a simulator for the intel 8086 processor in

22 messages 2007/08/17

[#265223] Problem with Array#delete — Matthew B Gardner <weather@...>

Hello, I'm baffled by the following problem:

16 messages 2007/08/18
[#265226] Re: Problem with Array#delete — Morton Goldberg <m_goldberg@...> 2007/08/18

On Aug 18, 2007, at 12:59 AM, Matthew B Gardner wrote:

[#265230] Re: Problem with Array#delete — Matthew B Gardner <weather@...> 2007/08/18

Sorry, I only meant the code I posted as an example of what is happening --

[#265244] How do you print the first 5 records in an array? — Bob Sanders <small.business.strategy@...>

Let's say I have an array defined as:

29 messages 2007/08/18

[#265273] Emulating a Groovy feature? — John Wells <lists@...>

Guys,

17 messages 2007/08/18

[#265303] Is this the perfect regex for validating first & last names? — Todd Burch <promos@...>

Perhaps a fairly bold statement, coming from a novice regex'er. :)

11 messages 2007/08/18

[#265381] Detecting duplicates in an array, anything in the standard library ? — Thibaut Barr鑽e <thibaut.barrere@...>

Hi!

35 messages 2007/08/19
[#265594] Re: Detecting duplicates in an array, anything in the standard library ? — Pe, Botp <botp@...> 2007/08/21

From: Thibaut Barr鑽e [mailto:thibaut.barrere@gmail.com]

[#265614] Re: Detecting duplicates in an array, anything in the standa — Jimmy Kofler <koflerjim@...> 2007/08/21

Duplicates can also be extracted from an array like this:

[#265488] Current rubygems require idiom — Bil Kleb <Bil.Kleb@...>

Hi,

15 messages 2007/08/20

[#265543] Regexp: named captures — Ari Brown <ari@...>

How do named captures in Ruby work? This is what I've tried:

21 messages 2007/08/20

[#265592] Dear Lazyweb: Gem Platforms — Eric Hodel <drbrain@...7.net>

As you may or may not have heard, RubyGems will be merged into Ruby

14 messages 2007/08/21

[#265596] Test if file is binary ? — "Rebhan, Gilbert" <Gilbert.Rebhan@...>

26 messages 2007/08/21

[#265635] How to "cast" in Ruby — Marcin Tyman <m.tyman@...>

Hi,

15 messages 2007/08/21
[#265636] Re: How to "cast" in Ruby — "David A. Black" <dblack@...> 2007/08/21

Hi --

[#265729] Get Date Modified value for a directory (folder) — Hayato Iriumi <hiriumi@...>

Hello, folks.

12 messages 2007/08/22

[#265843] time class changed in ruby-1.8.6? — "Ball, Donald A Jr (Library)" <donald.ball@...>

Hi guys. I'm in the process of migrating a ruby app from 1.8.5 to 1.8.6

11 messages 2007/08/22

[#265888] ruby shell? — "Simon Schuster" <significants@...>

what about a shell based on ruby? would such a thing be

26 messages 2007/08/23
[#265892] Re: ruby shell? — "Robert Klemme" <shortcutter@...> 2007/08/23

2007/8/23, Simon Schuster <significants@gmail.com>:

[#265930] Re: ruby shell? — "Daniel Aquino" <mr.danielaquino@...> 2007/08/23

It would be cool if we could some how write a patch that would alter

[#265971] Functional Programming — benjohn@...

I'm interested in functional programming.

26 messages 2007/08/23
[#266017] Re: Functional Programming — Brian Adkins <lojicdotcom@...> 2007/08/23

On Aug 23, 1:32 pm, benj...@fysh.org wrote:

[#266080] Re: Functional Programming — Sharon Phillips <phillipsds@...> 2007/08/24

> If you like Ruby, you may also enjoy Lisp since it influenced Ruby.

[#266039] something I just found out, am sharing (:newbish) — "Simon Schuster" <significants@...>

075:0> a = "hello"

13 messages 2007/08/24

[#266067] How to append some data at the beginning of a file — Uday Thokala <udaykanth_t@...>

Hi,

10 messages 2007/08/24

[#266085] ID3 Tags (#136) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

38 messages 2007/08/24

[#266087] Combining Array Elements — gregarican <greg.kujawa@...>

I have an array that I would like to combine elements. Here's a sample

14 messages 2007/08/24

[#266159] Thread safety techniques for server applications? — Aaron Smith <beingthexemplary@...>

Hey all,

24 messages 2007/08/25
[#266173] Re: Thread safety techniques for server applications? — "dtuttle1@..." <dtuttle1@...> 2007/08/25

Hi Aaron,

[#266190] Re: Thread safety techniques for server applications? — khaines@... 2007/08/25

On Sat, 25 Aug 2007, dtuttle1@gmail.com wrote:

[#266199] Re: Thread safety techniques for server applications? — "Terry Poulin" <bigboss64@...> 2007/08/25

> Remember that Ruby threads, being green threads, are all in the same

[#266202] Re: Thread safety techniques for server applications? — "ara.t.howard" <ara.t.howard@...> 2007/08/25

[#266162] How can I make this if/else more succinct? — eggie5 <eggie5@...>

How can I make this if/else more succinct?

13 messages 2007/08/25

[#266274] Ruby Vs. Java — Nick Nick <schaefer88@...>

Which programming language is faster - Ruby or Java?

49 messages 2007/08/26
[#266276] Re: Ruby Vs. Java — "simon jenkins" <simojenki@...> 2007/08/26

It depends what you mean by faster,

[#266280] Re: Ruby Vs. Java — Nick el <schaefer88@...> 2007/08/26

[#266293] Re: Ruby Vs. Java — Phrogz <phrogz@...> 2007/08/26

On Aug 26, 6:16 am, Nick el <schaefe...@gmail.com> wrote:

[#266304] Re: Ruby Vs. Java — "I. P." <stack.tcpip@...> 2007/08/26

|Phrogz|

[#266279] 2D MMORPG — Nick el <schaefer88@...>

I've been trying to find out what programming language would be best for

20 messages 2007/08/26

[#266285] sort_by { rand } not working — Mike Dershowitz <michael.dershowitz@...>

Hello:

22 messages 2007/08/26

[#266309] Why does: system("./ati-driver-installer-8.40.4-x86.x86_64.run --buildpkg Ubuntu/feisty") not work ? It always fails without any error? — kazaam <kazaam@...>

Well,

11 messages 2007/08/26

[#266403] Ruby Pocket Reference — John Joyce <dangerwillrobinsondanger@...>

I picked up the new OREILLY book Ruby Pocket Reference today, by

23 messages 2007/08/27
[#266414] Re: Ruby Pocket Reference — Thomas Worm <usenet@...4r.de> 2007/08/27

On Mon, 27 Aug 2007 14:39:53 +0900, John Joyce wrote:

[#266452] Re: Ruby Pocket Reference — Karl von Laudermann <doodpants@...> 2007/08/27

On Aug 27, 3:58 am, Thomas Worm <use...@s4r.de> wrote:

[#266456] Re: Ruby Pocket Reference — "Kyle Schmitt" <kyleaschmitt@...> 2007/08/27

But ruby already _has_ animals.

[#266464] Re: Ruby Pocket Reference — John Joyce <dangerwillrobinsondanger@...> 2007/08/27

No, I'm not that dense, I know OREILLY chooses random animals at

[#266471] Substitution within system quoted string — "Victor Reyes" <victor.reyes@...>

Team,

11 messages 2007/08/27

[#266497] IDE's With Indentation Guides Like SciTE? — "list. rb" <list.rb@...>

I've used SciTE for quite some time now and have become addicted to the

18 messages 2007/08/28

[#266616] idiomatic way to assign if not nil? — Jay Levitt <jay@...>

I know I can use "a ||= b" to assign b to a if a is nil.

21 messages 2007/08/28

[#266664] Difference between Distributed ruby and Rinda — Hema Latha <hema_aspire@...>

Can anyone tell me the difference between Distributed ruby and rinda?

9 messages 2007/08/29

[#266728] How to make an array of hashes to a single array with all the values of these hashes ? — kazaam <kazaam@...>

Take a look at this,

13 messages 2007/08/29
[#266731] Re: How to make an array of hashes to a single array with all the values of these hashes ? — Phrogz <phrogz@...> 2007/08/29

On Aug 29, 12:39 pm, kazaam <kaz...@oleco.net> wrote:

[#266768] Bug in % (Float)? — "Charlie Lehardy" <charlie.lehardy@...>

Modulo should be a fairly simple operation, however I'm finding some very

25 messages 2007/08/30
[#266781] Re: Bug in % (Float)? — Pe, Botp <botp@...> 2007/08/30

From: Charlie Lehardy [mailto:charlie.lehardy@gmail.com] :

[#266789] Re: Bug in % (Float)? — Morton Goldberg <m_goldberg@...> 2007/08/30

On Aug 29, 2007, at 10:14 PM, Pe, Botp wrote:

[#266794] Re: Bug in % (Float)? — Calamitas <calamitates@...> 2007/08/30

On 30/08/2007, Morton Goldberg <m_goldberg@ameritech.net> wrote:

[#266804] Re: Bug in % (Float)? — Morton Goldberg <m_goldberg@...> 2007/08/30

On Aug 30, 2007, at 3:39 AM, Calamitas wrote:

[#266865] Re: Bug in % (Float)? — Calamitas <calamitates@...> 2007/08/30

On 30/08/2007, Morton Goldberg <m_goldberg@ameritech.net> wrote:

[#266975] Re: Bug in % (Float)? — Morton Goldberg <m_goldberg@...> 2007/08/31

On Aug 30, 2007, at 5:56 PM, Calamitas wrote:

[#266806] Important Research Project — "E.D.G." <edgrsprj@...>

Important Research Project (Related to computer programming)

15 messages 2007/08/30

[#266841] Changing date backward messes up threaded sleep — Earle Clubb <eclubb@...>

Can anyone explain this behavior? If the system time is set backward,

13 messages 2007/08/30

[#266882] 0.06 == 0.06 returns false in Ruby? — "Jason G." <jasonpurchase@...>

Hi

45 messages 2007/08/31
[#266885] Re: 0.06 == 0.06 returns false in Ruby? — Peña, Botp <botp@...> 2007/08/31

From: Jason G. [mailto:jasonpurchase@yahoo.com]

[#266914] Re: 0.06 == 0.06 returns false in Ruby? — Michael Ulm <michael.ulm@...> 2007/08/31

Pe単a wrote:

[#266924] Re: 0.06 == 0.06 returns false in Ruby? — Daniel DeLorme <dan-ml@...42.com> 2007/08/31

Michael Ulm wrote:

[#266931] Re: 0.06 == 0.06 returns false in Ruby? — "Robert Klemme" <shortcutter@...> 2007/08/31

2007/8/31, Daniel DeLorme <dan-ml@dan42.com>:

[#266933] Re: 0.06 == 0.06 returns false in Ruby? — Pe, Botp <botp@...> 2007/08/31

From: Robert Klemme [mailto:shortcutter@googlemail.com]

[#266894] Ruby stupidities — Kenneth McDonald <kenneth.m.mcdonald@...>

The title is intentionally (but semiseriously) contentious, but I'm not

16 messages 2007/08/31

[#266945] Twisting a Rope (#137) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

32 messages 2007/08/31

Re: Problem with Array#delete

From: Robert Klemme <shortcutter@...>
Date: 2007-08-18 12:14:57 UTC
List: ruby-talk #265269
On 18.08.2007 11:44, Matthew B Gardner wrote:
> I went a little different route, but that was indeed the problem. I just 
> defined == in my class, which I guess was comparing the class of the object 
> instead of the object_id. I did:
> 
> def == obj
> 	self.equal?(obj)
> end
> 
> If you have time, or if someone else does, is there a quick explanation of why 
> this happened in this instance,

If you just defined == the way you presented above then the issue should 
not have occurred because equal? tests for identity.  It's difficult to 
comment on fragments when the whole code is not presented.

> but not with similar classes that function 
> fine with essentially duplicate methods of adding to and deleting from 
> arrays?

I am not sure what you mean by this.  Can you elaborate?

> Hopefully I can avoid future problems if I understand what's 
> happening (I'm a hobby programmer, so I lack some technical expertise).

There are some concepts you should keep in mind that have some 
similarities and will typically wreck havoc on your code when confused. 
   Both define relations (in the mathematical sense) on objects.

First, there is "identity".  Two objects are identical when they are 
actually just one, i.e. the same instance.

Then, there is equivalence.  Equivalence is defined per class.  For 
example two strings containing the same sequence of characters are 
equivalent.  Sometimes only identical instances are equivalent.

Now, these different concepts are implemented in Ruby via different methods:
eql? and == implement equivalence
equal? implements identity

Most containers (an Array is a container) use equivalence, namely 
implemented via eql? to test whether some objects match (e.g. for 
deletion), because it is the more flexible and more useful concept. 
(Think of an Array of Strings and you want to delete one of them with a 
certain character sequence, you would want to provide a string with that 
sequence as template and not the exact same object in the array - which 
you might not know beforehand.)

Now, there is a slight twist: since for some algorithms it's not 
efficient to compare something against all elements in the container 
(for example, Array#uniq would have to compare every element of the 
array with every other element which is O(n*n), i.e. if you double the 
elements in the Array you quadruple the number of comparisons 
necessary).  In those cases (unfortunately they are not all documented) 
typically a Hash is used behind the scenes.  For objects to work 
properly as Hash key methods eql? *and* hash need to be implemented 
properly.

Consequence is, that you should always implement eql? and hash (and also 
== for consistency) reasons *if* you plan to use instances of your class 
in these circumstances *and* want to define equivalence different than 
via identity (which happens to be the default implementation in class 
Object).  Typically you will choose some fields for this and you must 
also make sure that equivalent instances yield the same (!) hash code. 
Normally you do that by applying some math operation (binary XOR is 
frequently used, because it's fast and guarantees that all values used 
influence the result) on the hash values of those members that you 
determine as key elements for equivalence.

The easiest way to do that is by using Struct, because that will 
generate a class with all the necessary methods.  Example:

# name and age are key for Foo
Foo = Struct.new :name, :age do
   attr_accessor :unimportant_other_attribute
end


irb(main):007:0> f1 = Foo.new("a", 10)
=> #<struct Foo name="a", age=10>
irb(main):008:0> f2 = Foo.new("a", 10)
=> #<struct Foo name="a", age=10>
irb(main):009:0> f1.hash
=> -2186440
irb(main):010:0> f2.hash
=> -2186440
irb(main):011:0> f1.eql? f2
=> true
irb(main):012:0> f1 == f2
=> true
irb(main):013:0> f1.equal? f2
=> false
irb(main):014:0> f1.unimportant_other_attribute = "bar"
=> "bar"
irb(main):015:0> f1.eql? f2
=> true
irb(main):016:0> f1.name = "hello"
=> "hello"
irb(main):017:0> f1.eql? f2
=> false

There is another thing you should be aware: numbers in Ruby actually 
implement *two* different equivalence relations:

irb(main):018:0> 1 == 1.0
=> true
irb(main):019:0> 1.eql? 1.0
=> false
irb(main):020:0> 1.hash
=> 3
irb(main):021:0> 1.0.hash
=> 233071

But most classes treat == and eql? synonym.

Next week we'll dive into ordering and operator <=>. :-))

Kind regards

	robert

In This Thread