gpt4 book ai didi

ruby - 第 5 章为什么是 Ruby : What is endertromb? 的辛酸指南

转载 作者:数据小太阳 更新时间:2023-10-29 07:48:52 25 4
gpt4 key购买 nike

谁能帮助我了解“endertromb”的使用方式,或者在本指南中我可以从哪里获得它? http://poignant.guide/book/chapter-5.html

为什么有 2 个例子,他试图教授有关实例变量的概念,但他似乎在请求文件 endertromb.rb 并使用它。我错过了什么吗?我怎样/怎样才能得到这个文件,这样我就不会出错。我试过谷歌,但一无所获。下面是他如何使用它的示例代码:

require 'endertromb'
class WishMaker
def initialize
@energy = rand( 6 )
end
def grant( wish )
if wish.length > 10 or wish.include? ' '
raise ArgumentError, "Bad wish."
end
if @energy.zero?
raise Exception, "No energy left."
end
@energy -= 1
Endertromb::make( wish )
end
end

最佳答案

Endertromb 只是在另一个文件中定义的一个类,这就是您需要知道的全部内容。正如 _why 他自己在本指南中所述:

Both the wish maker and the mind reader refer to a class named Endertromb. This class is stored in a file endertromb.rb, which is loaded with the code: require 'endertromb'.

The Endertromb class which contained the mysteries of this planet’s powers.

关于ruby - 第 5 章为什么是 Ruby : What is endertromb? 的辛酸指南,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5785424/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com