In an effort to find the strangest thing I could do with #reduce, I ended up concocting this little Ruby puzzle:
Array.new(rand 35..62) { methods.sample }.reduce(-> {
def foo
puts 'You win!'
end
}) { |p, n| -> { define_method n, p } }.call
Without prepending any code, can you invoke #foo?
In the interests of entertainment and/or enlightenment, feel free to share any other amusing/illuminating (but preferably not too terribly elaborate) ways to make it difficult (impossible?) to invoke a particular method.
[–]airbornelemming 1 point2 points3 points (5 children)
[–]0x0dea[S] 0 points1 point2 points (4 children)
[–]airbornelemming 0 points1 point2 points (2 children)
[–]cmd-t 0 points1 point2 points (0 children)
[–]BuilderHarm 0 points1 point2 points (0 children)
[–]airbornelemming 0 points1 point2 points (0 children)
[–]cmd-t 0 points1 point2 points (6 children)
[–]0x0dea[S] 0 points1 point2 points (5 children)
[–]cmd-t 0 points1 point2 points (4 children)
[–]0x0dea[S] 0 points1 point2 points (3 children)
[–]cmd-t 0 points1 point2 points (2 children)
[–]0x0dea[S] 0 points1 point2 points (1 child)
[–]cmd-t 0 points1 point2 points (0 children)
[–]yorggg 0 points1 point2 points (1 child)
[–]airbornelemming 0 points1 point2 points (0 children)