在这些方法中Math可被调用等一类的方法:
Math.cos(0)
Run Code Online (Sandbox Code Playgroud)
但也可以include像实例方法一样:
include Math
cos(0)
Run Code Online (Sandbox Code Playgroud)
相反,可以以一种方式调用以下模块,而不是另一种方式:
module Foo
def bar
end
end
Foo.bar() # NoMethodError for this call
include Foo
bar() # but this call is fine
Run Code Online (Sandbox Code Playgroud)
单身方法:
module Foo
def self.bar
end
end
Foo.bar() # this call is fine
include Foo
bar() # but not this one
Run Code Online (Sandbox Code Playgroud)
知道怎么写模块怎么样Math?
我在Windows下的VM上运行Linux.当我在Linux上使用Emacs时,由于我的键盘没有元键,我将按Esc,释放它,然后按下随后的字母键来执行我的元键命令.
如果命令是Ctrl-Meta-b怎么办?我以前的Esc方式不起作用,因为它取消了Ctrl.任何建议都将受到欢迎.(Emacs和Linux noob在这里,所以请不要笑,具体.)