MyTetra Share
Делитесь знаниями!
undef
Время создания: 31.08.2017 21:03
Текстовые метки: knowledge
Раздел: Ruby
Запись: xintrea/mytetra_db_mcold/master/base/1500542586h4iua0o2m9/text.html на raw.githubusercontent.com

Ruby undef Statement

This cancels the method definition. An undef cannot appear in the method body.

By using undef and alias, the interface of the class can be modified independently from the superclass, but notice it may be broke programs by the internal method call to self.

Syntax

undef method-name

Example

To undefine a method called bar do the following −

undef bar

-------------------


def tutu

puts "Angel & devils"

end


# Accounts.reading_charge

tutu()

undef tutu

tutu()

--------------------

Angel & devils

test.rb:18:in `<main>': undefined method `tutu' for main:Object (NoMethodError)

 
MyTetra Share v.0.59
Яндекс индекс цитирования