在格罗维耶,当我称之为地图构造者时,例如,
new Player(name: Lionel , surname: Messi , number: 10, team:barcelona)
我如何知道把财产设定者称为谁?
我需要知道这一点,因为我需要在我的一些组别中适用某种逻辑,我需要知道,在每一组别被点名时,会把哪些数据放在标的上。
在格罗维耶,当我称之为地图构造者时,例如,
new Player(name: Lionel , surname: Messi , number: 10, team:barcelona)
我如何知道把财产设定者称为谁?
我需要知道这一点,因为我需要在我的一些组别中适用某种逻辑,我需要知道,在每一组别被点名时,会把哪些数据放在标的上。
采用快速文字,似乎按通过顺序确定:
class Foo {
def settersCalled = []
def setFoo(foo) { settersCalled << foo }
def setBar(bar) { settersCalled << bar }
def setBaz(baz) { settersCalled << baz }
}
assert new Foo(foo: 0, bar: 0, baz: 0).settersCalled == [ foo , bar , baz ]
assert new Foo(bar: 0, foo: 0, baz: 0).settersCalled == [ bar , foo , baz ]
assert new Foo(baz: 0, bar: 0, foo: 0).settersCalled == [ baz , bar , foo ]
然而,你可以更多地了解格罗莫夫以夸张的方式遵循该守则。 如果你在该法典的一个编组中设置一个空白点,你就会注意到,打字机包括
Call me crazy, but I m the type of guy that likes constructors with parameters (if needed), as opposed to a constructor with no parameters followed by setting properties. My thought process: if the ...
While reading some stuff on the pImpl idiom I found something like this: MyClass::MyClass() : pimpl_( new MyClassImp() ) First: What does it mean? Second: What is the syntax? Sorry for being such ...
I ve a little doubt over this line: An anonymous class cannot define a constructor then, why we can also define an Anonymous class with the following syntax: new class-name ( [ argument-list ] ) {...
Here is the little code snippet: class A { public: A(int value) : value_(value) { cout <<"Regular constructor" <<endl; } A(const A& other) : value_(other....
Let s say I have the following class which I am not allowed to change: public class C { public C() { CreateSideEffects(); } public void M() { DoSomethingUseful(); } } and I have to call M ...
For example is this correct: class C { private: C(); C(const & C other); } or you should rather provide definition(s): class C { private: C() {}; C(const & C ...
I m a little confused about what is going on in Perl constructors. I found these two examples perldoc perlbot. package Foo; #In Perl, the constructor is just a subroutine called new. sub new { #I ...
Say you have this shell of a class: public class Number { private int value; public Number() : this(0) {} public Number(int initialValue) : this(initialValue, 0, 100) {} ...