Monday, November 29, 2010

concise and expressive

This is the kind of stuff that amazes me about Ruby:

line = "/pop/mente_al_sol.mp3 | 3:45 | El niño gusano | Pon tu mente al Sol"
filename, length, artist, album = line.split(/\|/))

Isn't that just plain nice!?

Example adapted from the Programming Ruby, the pragmatic programmers guide.

No comments:

Post a Comment