From: Brian Candler Date: 2012-12-07T02:50:37+09:00 Subject: Re: Array#concat Enumerator Well, the documentation of concat is explicit that it requires an array argument: ary.concat(other_ary) -> ary ------------------------------------------------------------------------------ Appends the elements of other_ary to self. [ "a", "b" ].concat( ["c", "d"] ) #=> [ "a", "b", "c", "d" ] I suppose it could call to_a or Array() implicitly on its argument, but that might have unforeseen behaviour. Otherwise it could call other_ary.each and add the yielded elements one by one, which would work with anything that duck-types Enumerable. However I imagine this would be a lot slower if you're actually just concatenating an Array. I would quite like all Enumerables to be lazy - so for example arr.map{} returns an Enumerator, and you can run map and select on infinite enumerations. If this were the case, concat would be lazy too. But that's not going to happen. -- Posted via http://www.ruby-forum.com/.