草庐IT

argument1

全部标签

ruby - "wrong number of arguments (1 for 0)"在 Ruby 中是什么意思?

“参数错误:参数数量错误(1代表0)”是什么意思? 最佳答案 当您定义一个函数时,您还定义了该函数需要工作的信息(参数)。如果它被设计为在没有任何额外信息的情况下工作,并且你传递了一些信息,你就会得到那个错误。例子:不接受参数:defdogend接受参数:defcat(name)end当你调用它们时,你需要用你定义的参数来调用它们。dog#worksfinecat("Fluffy")#worksfinedog("Fido")#ReturnsArgumentError(1for0)cat#ReturnsArgumentError(0f

javascript - Array.prototype.slice.call(arguments) 与 Array.prototype.slice.apply(arguments)

上一个posts已经讨论过Array.prototype.slice.call(arguments)是如何工作的,但我不明白你为什么使用call而不是apply当apply用于类似数组的对象时,而call用于以逗号分隔的对象列表。arguments不是应该使用apply而不是call的类数组对象吗? 最佳答案 如果您想将参数传递给数组中的slice而不是一个一个地传递,那就有区别了。你可以这样做[1,2,3,4,5,6,7]----ourexampleargumentsArray.prototype.slice.call(argum

JavaScript 约定 : How do you assign arguments to the parent scope

varproblemtest=function(){varparameters;returnfunction(parameters){parameters=parameters;}}varmysolutiontest=function(){varparameters;returnfunction(parametersIn){parameters=parametersIn;}}这更像是一个JavaScript约定问题。通常我在上面有类似的代码。函数接受参数并将其分配给父范围。但是,我不能像在problemtest中那样使用它,因为作为参数的parameters隐藏了problemtest

javascript - 语法错误 : invalid arrow-function arguments (parentheses around the arrow-function may help)

这样的代码会产生一个错误:if(hr>t1[0]||(hr==t1[0]&&min=>t1[1])&&hr错误:SyntaxError:无效的arrow-function参数(arrow-function周围的括号可能有帮助)这是什么意思,它是如何发生的?Google搜索此错误毫无用处。编辑:似乎是使用=>=而不是=引起的。但我仍然很好奇为什么错误是这样表述的,以及箭头函数应该是什么。编辑2.首先,我没有意识到这实际上可能是特定于浏览器的问题。另外,我没有意识到现在人们在浏览器上下文之外的其他地方使用JS。所以,为了说明这一点,我的浏览器是MozillaFirefox25.0.1。

javascript - arguments 属性可以通过 this.some_function.arguments 访问吗?其实我无法解释?

我在读一本JavaScript书,我在读如何通过原型(prototype)扩展JavaScript数组的数组功能,然后我来到这个我无法理解的例子,也没有对它进行深入的解释,我不是能够理解:Array.prototype.some_function=function(){varargs=this.some_function.arguments;//1varargs_length=this.some_function.arguments.length;//2...}//some_function在这里我能够访问参数,但我不知道这是如何工作的,意思是this指的是我们调用此方法的对象(在此上

javascript - "Error: Arguments array must have arguments."应用模块

在我的Angular应用程序中运行ngserve并成功编译时,我开始在浏览器控制台中收到以下错误。AppComponent_Host.ngfactory.js?[sm]:1ERRORError:Argumentsarraymusthavearguments.atinjectArgs(core.js:1412)atcore.js:1491at_callFactory(core.js:8438)at_createProviderInstance(core.js:8396)atresolveNgModuleDep(core.js:8371)atNgModuleRef_.push../node

javascript - this.initialize(arguments) 与 this.initialize.apply(this, arguments) : what's the difference?

如果您查看Backbone.js的源代码,您会看到此模式的多种用途:this.initialize.apply(this,arguments);例如,这里:varRouter=Backbone.Router=function(options){options||(options={});if(options.routes)this.routes=options.routes;this._bindRoutes();this.initialize.apply(this,arguments);};为什么不直接写this.initialize(arguments)呢?

javascript - IE11 上的 "Error: Invalid argument."

我在IE11上的Angular1.5.7中收到下面列出的错误。Angular不会在Chrome上抛出任何错误。我尝试了以下方法:我看到帖子暗示这与内插值有关,例如“{{model.label}}”,所以我添加了一个ng-if,但它没有帮助。已升级到最新的Angular:1.5.7。升级了jquery,因为我看到错误堆栈中列出了它。Error:Invalidargument.atinterpolateFnWatchAction(http://localhost:8080/mdp-js/app/assets/angular/angular.js:9621:17)atinterpolateF

javascript - Angular AOT : ERROR in ng component html file : Expected 0 arguments, 但得到 1

最初我在发布angular.net核心SPA应用程序时遇到以下错误:Can'tresolverxjs/operatorsinrelease\directives我已经通过将rxjs版本更新到5.6解决了这个问题。现在在发布应用程序时出现以下错误:WARNINGinEnvironmentPlugin-NODE_ENVenvironmentvariableisundefined.Youcanpassanobjectwithdefaultvaluestosuppressthiswarning.Seehttps://webpack.js.org/plugins/environment-plug

javascript - Firebase promise - Query.once 失败 : Was called with 1 argument. 预计至少 2

我正在尝试使用promises将来自Firebase的一些数据填充到一个数组中。这是数据库结构:-domainname(orsomething)|--highscore|--Foo:50|--Bar:60代码:vararr=[];highscoreRef.child('highscore').once('value').then(function(snapshot){snapshot.forEach(function(data){arr.push({playerName:data.key(),score:data.val()});});},function(error){console