开发者

from ObjectiveC to ECMAscript

开发者 https://www.devze.com 2022-12-29 09:41 出处:网络
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.

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}); 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号