As others have said, defnot a method, this is a keyword. You cannot "override" it. You can, however, define a method called "def" using Ruby metaprogramming:
define_method :def do
puts "this is a bad idea"
end
This will not override the keyword def, but you can call the new method with method(:def).call.
So, you are there (sort of).
Note. I have no idea why you want to define a method called def. Do not do this.
source
share