On Aug 24, 2009, at 16:36 , Jordan Fowler wrote:

> What about when you have a hash of hashes? For example:
> {:location => {
>     :city => {
>       :name => 'San Diego',
>       :population => 1_150_000
>     }
>     :state => 'CA'
>   }
> }
>
> Wouldn't it be handy to be able to say:
>
> location.city.population


I want the function and its args to be as natural as possible. So  
you'd pass that as:

some_fun :location => {:city... etc

and then use it as location[:city][:population], just as you would if  
you'd passed a hash to any regular function. If you want to do what  
you're proposing, you can still extend Hash accordingly.

I'm trying to make it as simple as I can to write functions that take  
arguments by name, with meta-information and attendant behavior  
happening automatically, such as which ones are required, have default  
values etc. I don't want to do any more than that.

Regards,

Guyren G Howe
Relevant Logic LLC

guyren-at-relevantlogic.com ~ http://relevantlogic.com ~ +1 512 784 3178

Ruby/Rails,  REALbasic, PHP programming
PostgreSQL, MySQL database design and consulting
Technical writing and training

Read my book, Real OOP with REALbasic: 
<http://relevantlogic.com/oop-book/about-the-oop-book.php 
 >


--~--~---------~--~----~------------~-------~--~----~
SD Ruby mailing list
sdruby@googlegroups.com
http://groups.google.com/group/sdruby
-~----------~----~----~----~------~----~------~--~---

Reply via email to