草庐IT

argument2

全部标签

ruby - 参数错误 : wrong number of arguments in Ruby

试图解决这个问题,classPersondefinitialize(name)@name=nameenddefgreet(other_name)puts"Hi#{other_name},mynameis#{name}"endendinitialize("ak")greet("aks")但我收到如下错误:ArgumentError:wrongnumberofargumentscalling`initialize`(1for0)我不明白这里问的是什么,如果它只是参数那么为什么错误就像(1对0)。有人可以帮我理解这个问题。 最佳答案 看这

ruby - 类型错误 : wrong argument type with Ruby &~ operator

我尝试比较我的Ruby应用程序中的标志。我有这段代码:ifself.flag&~flag==self.flagreturnfalse但是它不会运行。我已将问题范围缩小到:irb(main):020:0>my_user.flag=>1irb(main):021:0>flag=>128irb(main):022:0>my_user.flag.class=>Fixnumirb(main):023:0>flag.class=>Fixnumirb(main):024:0>my_user.flag&~flagTypeError:wrongargumenttypeFixnum(expectedPro

ruby - 我怎样才能使用 Gemfile 的 :path argument to reference local gems in development with a value that is OS agnostic?

我正在编写一个Gemfile来帮助开发我的团队正在创建的一些gem。我知道Gemfile允许使用:path参数来引用包含.gemspec文件的本地目录:gem"my_gem",:path=>"../Ruby_Libs/my_gem"但是,我的团队成员在编写代码时使用不同的操作系统(OSX、WinXP、Win7)。所以我的问题是如何使用Gemfile的:path参数来引用开发中的本地gem,其值与操作系统无关? 最佳答案 使用File.join('..','Ruby_Libs','my_gem'')而不是"../Ruby_Libs/m

c++ - 从 v8::Arguments 转换为 C++ 类型

我正在尝试用C++创建Node.js模块,但我对v8::Arguments类感到困惑。假设我有一个用于发送电子邮件的Javascript类,它有一个带有此签名的方法:Mailer::sendEmail(Arrayrecipients,Stringsender,Stringmessage);会这样调用:mailer.sendEmail(["joe@gmail.com","sally@gmail.com"],"fred@gmail.com","Hithere");现在在C++领域,我有一个带有这个签名的类函数:SendEmail(constv8::Arguments&args)在Javas

c++ - 从 v8::Arguments 转换为 C++ 类型

我正在尝试用C++创建Node.js模块,但我对v8::Arguments类感到困惑。假设我有一个用于发送电子邮件的Javascript类,它有一个带有此签名的方法:Mailer::sendEmail(Arrayrecipients,Stringsender,Stringmessage);会这样调用:mailer.sendEmail(["joe@gmail.com","sally@gmail.com"],"fred@gmail.com","Hithere");现在在C++领域,我有一个带有这个签名的类函数:SendEmail(constv8::Arguments&args)在Javas

c++ - GCC 问题 : using a member of a base class that depends on a template argument

以下代码不能用gcc编译,但可以用VisualStudio编译:templateclassA{public:Tfoo;};templateclassB:publicA{public:voidbar(){cout我得到错误:test.cpp:Inmemberfunction‘voidB::bar()’:test.cpp:11:error:‘foo’wasnotdeclaredinthisscope但它应该是!如果我将bar更改为voidbar(){coutfoo然后它确实编译,但我不认为我必须这样做。GCC在此处遵循的C++官方规范中是否有某些内容,还是只是一个怪癖?

c++ - GCC 问题 : using a member of a base class that depends on a template argument

以下代码不能用gcc编译,但可以用VisualStudio编译:templateclassA{public:Tfoo;};templateclassB:publicA{public:voidbar(){cout我得到错误:test.cpp:Inmemberfunction‘voidB::bar()’:test.cpp:11:error:‘foo’wasnotdeclaredinthisscope但它应该是!如果我将bar更改为voidbar(){coutfoo然后它确实编译,但我不认为我必须这样做。GCC在此处遵循的C++官方规范中是否有某些内容,还是只是一个怪癖?

c++ - 关于c++转换: no known conversion for argument 1 from ‘[some_class]' to ‘[some_class]&’

我正在使用C++,但出现了一个我不知道确切原因的错误。我找到了解决方案,但仍然想知道为什么。classBase{public:voidsomething(Base&b){}};intmain(){Baseb;b.something(Base());return0;}当我编译代码时,出现以下错误:abc.cpp:12:20:error:nomatchingfunctionforcallto‘Base::something(Base)’abc.cpp:12:20:note:candidateis:abc.cpp:6:7:note:voidBase::something(Base&)abc.

c++ - 关于c++转换: no known conversion for argument 1 from ‘[some_class]' to ‘[some_class]&’

我正在使用C++,但出现了一个我不知道确切原因的错误。我找到了解决方案,但仍然想知道为什么。classBase{public:voidsomething(Base&b){}};intmain(){Baseb;b.something(Base());return0;}当我编译代码时,出现以下错误:abc.cpp:12:20:error:nomatchingfunctionforcallto‘Base::something(Base)’abc.cpp:12:20:note:candidateis:abc.cpp:6:7:note:voidBase::something(Base&)abc.

c++ - C2977 : 'std::tuple' : too many template arguments (MSVC11)

我正在尝试使用VisualC++11构建googletest,但以下代码会导致错误templatevoidPrintTo(const::std::tr1::tuple&t,//这是一个错误文本:f:\gtest-1.6.0\include\gtest\gtest-printers.h(550):errorC2977:'std::tuple':toomanytemplateargumentsc:\programfiles(x86)\microsoftvisualstudio11.0\vc\include\utility(72):seedeclarationof'std::tuple'还有