A
Ara.T.Howard
i've been toying with an idea lately and thinking about how one would crawl an
object graph to determine if it matched a specifc object. for instance
array_of_hashes = [ {}, {} ]
specific_array_of_hashes = [ {'key' => 'value}, {:k => :v} ]
specific_array_of_hashes_2 = [ {:k => :v} ]
specific_array_of_hashes.is_shaped_like? array_of_hashes #=> true
so, something like pattern matching in ml languages. any concepts on how to
do that in ruby for arbitrary objects?
cheers.
-a
--
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| Your life dwells amoung the causes of death
| Like a lamp standing in a strong breeze. --Nagarjuna
===============================================================================
object graph to determine if it matched a specifc object. for instance
array_of_hashes = [ {}, {} ]
specific_array_of_hashes = [ {'key' => 'value}, {:k => :v} ]
specific_array_of_hashes_2 = [ {:k => :v} ]
specific_array_of_hashes.is_shaped_like? array_of_hashes #=> true
so, something like pattern matching in ml languages. any concepts on how to
do that in ruby for arbitrary objects?
cheers.
-a
--
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| Your life dwells amoung the causes of death
| Like a lamp standing in a strong breeze. --Nagarjuna
===============================================================================