Chicago: in fashion
2007-04-13 12:04:00 -0400I’m in Chicago tonight for another job interview tomorrow. Never been to Chicago before, so that’s very cool, and I’m excited about the interview. Not much more to say except that downtown Chicago is stunning (and I get a 28th-floor view here), and that overriding Proc#call
does not in fact affect the behavior of yield
. Nobody expects the Spanish inquisition:
class Proc
def weird(*args)
# Only get all weird if we ask for it.
puts "weird call!" if args.length > 0 && args[0] == "weird"
orig_call(*args)
end
alias :orig_call :call
alias :call :weird
end
def weird_call(str, &block)
block.call(str)
end
def weird_yield(str)
yield(str)
end
and you get:
>> weird_call("weird") { true }
weird call!
=> true
>> weird_yield("weird") { true }
=> true
This is frustrating, because I wanted Handshake to be able to support:
contract Block(String => Integer) => 1..5
For example. Am I wrong? Or is there another mechanism for overriding the behavior of yield
?
The degree to which Ruby’s core methods don’t appear to be orthogonal, instead employing lower-level mechanisms to do their work (Class#===
vs. Object#is_a?
is another example) has been an unpleasant surprise to me.