diff --git a/rules/0280-Ruby.md b/rules/0280-Ruby.md index affb758..bf56a2c 100644 --- a/rules/0280-Ruby.md +++ b/rules/0280-Ruby.md @@ -8,5 +8,19 @@ Codewars [uses Ruby 2.0](http://www.codewars.com/docs/ruby-environment). The testing framework is [inspired](http://www.codewars.com/docs/ruby-test-reference) by [RSpec](http://rspec.info/documentation/), but not 100% compatible. +### Disabling built-in functions and methods + +Ruby probably offers the best and most direct way to do that, thanks to the `undef` command. + +To work with it, just put it inside the `Class` that you want to be affected, like this example to disable additions and multiplication for Integers: + +```ruby +class Fixnum + undef :+,:* +end +``` + +Notice that in this way nothing prevents a sly user from just converting your numbers to `Float`, using the undefined operators and then converting to integers again, so be very scrupulous when you plan to undef some function, as you might need to do so in more than one form, more than one class and/or prevent conversions back and forth other classes. +