Usare grep con ruby

Posted by Dibi Store Wed, 09 Jan 2008 10:29:00 GMT

Si, si può, il metodo fa parte del modulo enumerable, di seguito un esempio di utilizzo con rails:

  User.find(:first).attributes.keys.grep(/privacy/)
  => ["privacy", "third_parties_privacy"]

Figo no?

Posted in  | Tags  | no comments | no trackbacks

Comments

Trackbacks

Use the following link to trackback from your own site:
http://www.dibistore.com/trackbacks?month=01&year=2008&article_id=usare-grep-con-ruby&day=09

(leave url/email »)

   Preview comment