from ObjectiveC to ECMAscript
Going thru the excellent Apress books on Objective C. To help in my undertanding, I try and recode any Ojective C code samples in Java/Action-script. One common structure in method calls in ObjC leaves me a bit puzzled.
-(id) initWithPressure: (f开发者_Go百科loat) pressure
treadDepth: (float) treadDepth;
(in ECMAscript)Would this be most similar to 1 method call with multiple arguments OR 2 method calls, each with a single argument?
That's a single method call with two arguments; probably something like:
function initWithPressureAndTreadDepth(float pressure, float treadDepth);
I think a parameter object with named fields is a good substitute for the Objective-C concept.
function initWith(arg)
{
if(arg.pressure < 10.0)
{
...
}
}
initWith({pressure: pressure, treadDepth: treadDepth});
精彩评论