Stoppt die Vorratsdatenspeicherung - www.vorratsdatenspeicherung.de

Rails Snippets

OK, this is more Ruby than Rails but nevertheless helpful…

If you come from a Perl background you will be surprised that in Ruby an array is definitively not a list. So if you want to pass a list of elements to a method that you have stored in an array, you may want to use the following idiom:
[code]]czoxMTU6XCJsaXN0ID0gW10NCmxpbmVzID0gRmlsZS5yZWFkbGluZXMoXCJGSUxFTkFNRVwiKQ0KbGluZXMuZWFjaCBkbyB8bGluZXwNCntbJiomXX1saXN0LnB1c2goUmVzdWx0Lm5ldygqbGluZS5zcGxpdChcIiBcIikpKQ0KZW5kDQpcIjt7WyYqJl19[[/code]
The [code]]czoxNjpcIipsaW5lLnNwbGl0KFwiIFwiKVwiO3tbJiomXX0=[[/code] creates an element list out of the array that the split command has created.

I fear a real Rubyist would have done it in a different way but OK.

P.S. Does someone know what I'm doing wrong with the code formatting in WordPress? I'm quite sure to have included whitespaces in the code above...

Tags: ,

Leave a Reply