2 ms·
Yeah, you've gotta immediately refactor that into a multiple_of function that takes an argument x and returns another function that takes an argument y and retu
by SilasX 14y ago
Yeah, you've gotta immediately refactor that into a multiple_of function that takes an argument x and returns another function that takes an argument y and returns whether it's a multiple of x.
Ah, Currying... (and how Firefox spellcheck recognizes that as a word, but not spellcheck)
*
On another note, I've seen other bizarre blind spots in experienced programmers. One time, when I was learning Ruby, I went to a Ruby "hack night" in SF where a bunch of people there explained that they had been hackers for a while. The group was given a challenge to implement C-style integers (with overflow/loop-around) using Ruby classes.
The session had "mentors" who were professional Ruby programmers (mainly with Rails).
So as I was writing my class, and implementing addition, I figured I would need to input another integer object and add its value. So I needed to know how to expose a member variable, and couldn't find the doc that said how, leading me to ask a mentor.
He was stumped. I was thinking, "WTF? You program Ruby all day but don't know how to write [what I later found was called] an accessor?" I wasn't asking for anything fancy, just the plain ol'
def foo
@foo
end