From: Ryan Davis Date: 2012-02-03T11:03:28+09:00 Subject: Re: Basic Ruby performance On Feb 2, 2012, at 17:36 , Josh Cheek wrote: > On Thu, Feb 2, 2012 at 7:01 PM, Ryan Davis wrote: > >> >> You're replacing a method call (a.match b) with a syntactic construct a =~ >> b, the latter of which bypasses method dispatch and goes straight to the >> C-implimentation. >> >> > Wow, I never knew that. I don't understand how it accomplishes this, a > could be any kind of object with =~ defined anywhere on it, how can it > bypass method dispatch? MAGIC! The code does extra type-checking at runtime. >> IMHO re.match is just as useless as Regexp.new, Array.new, and Hash.new >> (assuming no args/blocks passed). > > > I usually use `meth Hash.new` instead of `meth({})` I think it looks > cleaner. def meth h = {} # ... end takes care of this entirely.