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
- Jason King
Problem is that there are many things in the RFC that you specifically don’t want to accept as valid...
- Bryan Ray
@Mikel Excellent post. I’ve often had a hard time getting away from fixtures, because I like the added benefit you...
- marcus
it seems like he removed the pages, what a lost … :-( happen to have the pages saved offline ,...
- Mikel
Heya Zach,
That’s great to hear!
Thanks for updating the comments too! Much appreciated that you are letting others know...
- Zach Dennis
Mikel,
Ever since I posted my long winded comment I’ve been much more proactive in using inline helpers over before...
- grahame
He really nailed it. That is so true. Overly cautious on the first and “underly” cautious on the second.
That’s...
Leave a Reply