G
Greg Willits
In a language called Lasso I am used to a data structure of an array of
pairs:
$simpleArray = array( 'color', 'shape', 'size')
$arrayofPairs = array( 'color' = 'red', 'shape' = 'trapezoid', 'size' =
'small')
$simpleMap = map( 'color' = 'red', 'shape' = 'trapezoid', 'size' =
'small')
The difference between arrayofPairs and simpleMap is that the map (hash)
cannot gaurantee a specific order whereas the arrayofPairs does. It's an
array, so order is preserved. It also has what effectively works just
like hash keys. I can find, retrieve, and even sort based on the first
element of the pair. Lasso has a primitive data type of a Pair.
Does Ruby have a way to create this arrayofPairs? I don't see a data
type like a "pair" in Ruby, so not sure what to insert into each array
element to net this same data structure except I guess maybe an array of
single key hashes?
ideas? Thanks.
-- gw
pairs:
$simpleArray = array( 'color', 'shape', 'size')
$arrayofPairs = array( 'color' = 'red', 'shape' = 'trapezoid', 'size' =
'small')
$simpleMap = map( 'color' = 'red', 'shape' = 'trapezoid', 'size' =
'small')
The difference between arrayofPairs and simpleMap is that the map (hash)
cannot gaurantee a specific order whereas the arrayofPairs does. It's an
array, so order is preserved. It also has what effectively works just
like hash keys. I can find, retrieve, and even sort based on the first
element of the pair. Lasso has a primitive data type of a Pair.
Does Ruby have a way to create this arrayofPairs? I don't see a data
type like a "pair" in Ruby, so not sure what to insert into each array
element to net this same data structure except I guess maybe an array of
single key hashes?
ideas? Thanks.
-- gw