使用普通的javaScript而不是coffeeScript(Using plain javaScript instead of coffeeScript)
我的ruby on rails应用程序必须使用coffeeScript还是可以我只需使用普通的javaScript?
Does my ruby on rails app have to use coffeeScript or could I can I Just use plain javaScript?
原文:https://stackoverflow.com/questions/20686236
最满意答案
我想你的问题实际上是
I_shape
,因为你的其他形状都需要3个参数。 我跑这个,它工作得很好,取代了None
不存在的类。此外,值得注意的是,使用名称修改(
__variable
)不需要99.9%的时间。 如果您想表明它是私密的,请使用单个下划线。I imagine your problem is actually in
I_shape
, given your other shapes all take 3 arguments. I ran this and it worked fine, replacing the classes that don't exist withNone
.Also, it's worth noting that using name mangling (
__variable
) is not needed 99.9% of the time. Use a single underscore if you want to indicate it's private.
相关问答
更多-
你错误地启动了你的课程。 试着这样做: m = Mazzo() m.Crea() 所以快速解释为什么。 首先,第一行初始化一个Mazzo类型的对象并设置为m(请注意'()'你需要为所有方法,初始化或其他方法。)由于它的唯一边界是self它可以留空。 接下来我们要调用Crea函数,我们通过调用刚创建的对象而不是类本身来完成。 You are initilizing your class incorrectly. Try doing this: m = Mazzo() m.Crea() So a quick ...
-
使用OOP导入Python(Python Importing with OOP)[2022-08-02]
您不直接在Class_C中使用Class_A或Class_B,因此您无需在那里导入它们。 额外的导入并不真正使用额外的内存,内存中每个模块只有一个实例。 Import只为当前模块名称空间中的模块创建名称。 在Python中,每个文件只有一个类不是惯用的。 将密切相关的类全部放在同一个文件中是很正常的。 模块名称“ClassA”看起来很愚蠢,即类的名称,而不是模块的名称。 如果在那里导入模块,您只能在另一个模块中使用。 例如,在Python启动之后, sys模块可能已经在内存中,因为很多东西都使用它,包括im ... -
Python:OOP开销?(Python: OOP overhead?)[2022-11-11]
这是因为Python解释器(CPython)正在进行动态查找以调度所有调用,索引等。动态查找允许语言具有很大的灵活性,但性能成本却很高。 当您使用“方法包装器”时,这(至少)正在发生: 查找mwp.id - 它碰巧是一个方法,但它也只是一个分配给属性的对象,必须像其他任何一样被查找 调用 mwp.id() 在方法内部,查找self._data 查看self._data的__getitem__ 调用 __getitem__ (至少这将是一个C函数,但你仍然必须通过所有这些动态查找来到这里) 相比之下,您的“D ... -
Python OOP和列表(Python OOP and lists)[2022-02-25]
问题在于你已经将data声明为类变量,因此该类的所有实例都共享同一个列表。 相反,将self.data = []放在您的__init__ 。 另外,摆脱所有这些分号。 它们是不必要的并且混乱了你的代码。 The problem is that you've declared data as a class variable, so all instances of the class share the same list. Instead, put self.data = [] in your __ini ... -
Python - OOP错误(Python - error with OOP)[2022-08-16]
您需要使用self变量引用data变量。 喜欢 - with open(self.data,'r') as f: You need to reference data variable using the self variable. Like - with open(self.data,'r') as f: -
我想你的问题实际上是I_shape ,因为你的其他形状都需要3个参数。 我跑这个,它工作得很好,取代了None不存在的类。 此外,值得注意的是,使用名称修改( __variable )不需要99.9%的时间。 如果您想表明它是私密的,请使用单个下划线。 I imagine your problem is actually in I_shape, given your other shapes all take 3 arguments. I ran this and it worked fine, repla ...
-
获取用户的输入,将其传递给汽车 class Car(object): def __init__(self, name): self.name = name ... etc etc user_name = input("What name do you want?") first_car = Car(user_name) 编辑:您也可以从类中调用input() : class Car(object): def __init__(self): self.n ...
-
Python OOP编程(Python OOP Programming)[2023-01-01]
v1 + v2被视为对v1.__add__(v2)的调用,其中self == v1和other == v2 。 v1 + v2 is treated as a call to v1.__add__(v2), with self == v1 and other == v2. -
这不仅是允许的,它基本上是你想要首先使用OO的主要原因:设计一个新类型Queue ,它就像一个内置类型。 考虑int 。 int有一些你不了解或不关心的内部状态。 1你关心的是,在某种程度上,它代表一个整数值,它提供了对该表示有意义的操作。 如果添加整数2和3并print结果,则得到输出5 。 这正是你用Queue做的。 就外界感兴趣而言,它以某种方式代表一系列物品,他们既不知道也不关心,只要它提供一贯有意义的操作,就像你的size 。 所以,现在something可以使用Queue实例作为其属性之一,与使 ...
-
验证者 - OOP(Validator - OOP)[2023-05-07]
正如错误消息所解释的那样, addValidator方法要求传递给它的第一个参数实现名为OOP_Validate_Interface的接口。 $validate->addValidator(new OOP_Validate_Int() /* <-- this argument must implement OOP_Validate_Interface */); 检查您的代码并将OOP_Validate_Int的类声明更改为: class OOP_Validate_Int implements OOP_Va ...