ruby - Map array, iterate nested array -


please refer following code:

x = 3 arr = ("a".."z").to_a arr2 = [1, 2, arr[ ], 4] arr3 = arr2.map * x 

desired output:

arr3 # => 12a412b412c4 

what best practice achieve output?

("a"..."z").first(3).map{|chr| [1, 2, chr, 4]}.join # => "12a412b412c4" 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -