2013-03-24 4 views
12

stavo indagando curses.rb del curses gemma, ho trovato questo ovunque:"Questo è uno stub, utilizzato per l'indicizzazione" nella maggior parte dei metodi?

def attrset(attrs) 
    #This is a stub, used for indexing 
end 
# bkgdset(ch) 
# 
# Manipulate the background of the current window 
# with character Integer +ch+ 
# 
# see also Curses.bkgdset 
def bkgdset(ch) 
    #This is a stub, used for indexing 
end 
# bkgd(ch) 
# 
# Set the background of the current window 
# and apply character Integer +ch+ to every character. 
# 
# see also Curses.bkgd 
def bkgd(ch) 
    #This is a stub, used for indexing 
end 
# Returns an Interer (+ch+) for the character property in the current window. 
def getbkgd() 
    #This is a stub, used for indexing 
end 

Non capisco la parte stub. Dov'è il codice che fa tutto il lavoro?

risposta

37

Sei, per caso, guardando questo con "Vai alla definizione" di RubyMine (o come si chiama lì)?

In tal caso, la ragione probabile è che tali metodi sono implementati in C e IDE non può mostrare il codice ruby, perché non ce n'è. Ma conosce le firme dei metodi e genera quei corpi falsi per aiutare il suo intellisense (completamento del nome del metodo e cose del genere).

+4

Woah, azzeccato. Questo spiega tutto. – ntl0ve