Deal of the Day
Get the Deal of the Day email alert
Home
»
Main
»
Manning Forums
»
2007
»
Ruby in Practice
Thread: Page 19: printable_attr
Welcome, Guest
Login / Register
Guest Settings
Reply to this Thread
Search Forum
Back to Thread List
Replies: 0
-
Pages: 1
Threads: [
Previous
|
Next
]
vcosby
Posts: 4
From: Bainbridge Island, WA
Registered: 5/22/06
Page 19: printable_attr
Posted: May 2, 2009 2:24 AM
Reply
I think you want "puts #{attr}" instead; "puts attr.to_s" won't work because attr won't be defined at runtime.
def printable_attribute(attr)
class_eval %{
def p_#{attr}
puts #{attr}
end
}
end
Legend
Gold: 300 + pts
Silver: 100 - 299 pts
Bronze: 25 - 99 pts
Manning Author
Manning Staff
Author Online
|
Login
|
Help
|
Search
Powered by Jive Software