Everyone knows two of the ways to create an empty array: Array.new and []. The first one is ‘standard’, you might say, and the second one is simply syntax sugar. Many different objects such as Hash and maybe even String are shorthanded through this method.
My question is: Is there a way to define my own delimimers for objects? An example would be <>. Maybe an alias like '<' => 'MyObject.new(' and '>' => ')'?
[]is an array literal,{}is a hash literal. There are plenty of these shorthand forms in Ruby. Check this wikibook out for more information.There is no object literal, but you can use (source):