Tuesday, February 16, 2010

Eval method in ruby

by Sandip Ransing 0 comments

Eval method in ruby executes string/expression passed as parameter.
Example:
irb > eval("5+3") => 8 irb > eval("a=5") => 5 irb > eval("b||=a") => 5
Its part of ruby meta-programming and not recommended approach unless there is no any alternative to do.

blog comments powered by Disqus

About The Author

Sandip is a ruby on rails developer based in pune and also a blogger at funonrails. Opensource contributor and working with Josh software Private Limited. for more info read Follow Sandip on Twitter for updates.

Connect With Me...

Github Projects

@sandipransing Twitter