首页 \ 问答 \ 使用普通的javaScript而不是coffeeScript(Using plain javaScript instead of coffeeScript)

使用普通的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
更新时间:2023-10-17 07:10

最满意答案

我想你的问题实际上是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 with None.

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 ...
  • 您不直接在Class_C中使用Class_A或Class_B,因此您无需在那里导入它们。 额外的导入并不真正使用额外的内存,内存中每个模块只有一个实例。 Import只为当前模块名称空间中的模块创建名称。 在Python中,每个文件只有一个类不是惯用的。 将密切相关的类全部放在同一个文件中是很正常的。 模块名称“ClassA”看起来很愚蠢,即类的名称,而不是模块的名称。 如果在那里导入模块,您只能在另一个模块中使用。 例如,在Python启动之后, sys模块可能已经在内存中,因为很多东西都使用它,包括im ...
  • 这是因为Python解释器(CPython)正在进行动态查找以调度所有调用,索引等。动态查找允许语言具有很大的灵活性,但性能成本却很高。 当您使用“方法包装器”时,这(至少)正在发生: 查找mwp.id - 它碰巧是一个方法,但它也只是一个分配给属性的对象,必须像其他任何一样被查找 调用 mwp.id() 在方法内部,查找self._data 查看self._data的__getitem__ 调用 __getitem__ (至少这将是一个C函数,但你仍然必须通过所有这些动态查找来到这里) 相比之下,您的“D ...
  • 问题在于你已经将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 ...
  • 您需要使用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 ...
  • 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实例作为其属性之一,与使 ...
  • 正如错误消息所解释的那样, 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 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)