Interesting method definition in ruby

2007-11-18 16:19:49 +0000

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?