From: dblack@... Date: 2006-01-08T07:38:39+09:00 Subject: Re: Demystifying Symbols. Hi -- On Sun, 8 Jan 2006, Dave Howell wrote: > > On Jan 6, 2006, at 8:48, Ross Bamford wrote: > >> On Fri, 06 Jan 2006 14:40:36 -0000, Dave Howell >> wrote: >> >>> P. S. With duck-typing as a Virtue in Rubyville, when am I ever going to >>> be presented with a method that won't accept a String as well as a Symbol? >>> Would there ever be a reason besides "bad programming" to be that >>> restrictive? >>> >> >> Here's one: >> >> f = File.read(:"/etc/passwd") >> >> TypeError: can't convert Symbol into String > > Hmm. But that's the opposite of what I said. I'm not too dismayed if > something says "no, no, I don't want a Symbol. I want an honest-to-gosh > String." It's if it says "No, a String is unacceptable. I only take Symbols" > that I'd be really perplexed. A number of methods in the various Rails libraries only work with symbol arguments. For example, you cannot do: SomeModel.find("all") or class SomeModel < ActiveRecord::Base has_many "others" end David -- David A. Black dblack@wobblini.net "Ruby for Rails", from Manning Publications, coming April 2006! http://www.manning.com/books/black