"这是一个存根,用于索引"在大多数方法中?

ntl*_*0ve 13 ruby rubymine

我研究curses.rb了的curses宝石,我发现这个无处不在:

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
Run Code Online (Sandbox Code Playgroud)

我不明白存根部分.实际完成所有工作的代码在哪里?

Ser*_*sev 42

你有没有机会用RubyMine的"Go to definition"(或者它在那里叫什么)来看这个?

如果是这样,那么可能的原因是这些方法是用C实现的,IDE不能显示ruby代码,因为没有.但是它知道方法签名并且它生成那些假身体来帮助它的intellisense(方法名称完成和东西).

  • 哇,现场.这解释了一切. (4认同)