From: Dave Bass Date: 2008-07-27T19:21:49+09:00 Subject: Re: Interesting Array Initialization Typo Regarding typos: Ruby can't be expected to know what you meant to type, so if it's syntactically correct it will let it through -- as with any language! To do otherwise would be as annoying as Microsoft's Clippy: "I see you're trying to set up an array. Did you just make a typo? " Shadowfirebird wrote: > a = [] > a << [1,2] > a << [2,3] > a << [3,4] Without any actual understanding of what's going on inside Ruby (sorry!), I suspect this code will be slower, as the array has to be grown three times, rather than springing into existence fully initialised. Or is this a negligible overhead? Or does the code get optimised by the compiler/interpreter? Maybe someone knowledgeable would like to comment. In particular it would be interesting to know if putting array pushes, pops, shifts and unshifts inside a big loop is inefficient. Dave -- Posted via http://www.ruby-forum.com/.