J
Joel VanderWerf
Hey, crazy idea. Why not use the same syntax for hashes and arrays? For
example:
{
1 => 2,
2 => 3,
3 => 4,
|x|
x + 1
}
This is essentially a hash with a default_proc that adds 1 to its argument.
Leave out the => pairs and you get something that acts like a proc.
Leave out the |...|... construct and you get something that acts like a
hash. With both, it's a hash with a default proc.
It's backwards compatible.
Are there any syntactic ambiguities?
example:
{
1 => 2,
2 => 3,
3 => 4,
|x|
x + 1
}
This is essentially a hash with a default_proc that adds 1 to its argument.
Leave out the => pairs and you get something that acts like a proc.
Leave out the |...|... construct and you get something that acts like a
hash. With both, it's a hash with a default proc.
It's backwards compatible.
Are there any syntactic ambiguities?