Interesting method definition in ruby
November 19th, 2007
Today, while doing some documentation on the TMail library, I found an interesting method declaration in the interface.rb file that has me stumped…
Here it is:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
def mime_version=( m, opt = nil ) if opt if h = @header['mime-version'] h.major = m h.minor = opt else store 'Mime-Version', "#{m}.#{opt}" end else store 'Mime-Version', m end m end |
Got any ideas on how do you call this method and pass a value to opt?
One possible way would be:
send('mime_version=', "1", "2") |
Got any others?
Recent Articles
Latest comments
- Dan Manges
+1. If you’re doing the same thing a few times, it’s not a problem to duplicate it. If you’re doing...
- Zach Dennis
David, I’m a little surprised by your response, seeing as you’re an advocate of outside-in development. How can you blackbox...
- Mikel
@david…
OOoooooooooooo…..............
Who’s ya daddy?!
Nice.
- David Chelimsky
I’m kind of with Mikel on this one from a philosophical stance – black box testing is less brittle.
But...
- David Chelimsky
Mikel – have you seen the ObjectDaddy library at http://github.com/flogic/object_daddy? It solves the same problem you’re solving here in a...
Leave a Reply