translate C# with => to unityscript

I’m trying to translate a piece of code from cs to unityscript, but I don’t understand the syntax. The code initializes the gree webview which adds webkit to unity. https://github.com/gree/unity-webview

The cs I’d like to translate to unityscript:

webViewObject.Init(
			cb: (msg) =>
			{
				Debug.Log(string.Format("CallFromJS[{0}]", msg));
				status.text = msg;
				status.GetComponent<Animation>().Play();
			},
			err: (msg) =>
			{
				Debug.Log(string.Format("CallOnError[{0}]", msg));
				status.text = msg;
				status.GetComponent<Animation>().Play();
			});

My attempt which does not work:

			webViewObject.Init( function(msg:String) {},function(err:String) {} );	

I don’t really understand why the original even works since it doesn’t even have the same arguments.
The cs parameters are defined here:

#if UNITY_EDITOR || UNITY_STANDALONE_OSX
    public void Init(Callback cb = null, bool transparent = false, string ua = @"Mozilla/5.0 (iPhone; CPU iPhone OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Version/7.0 Mobile/11D257 Safari/9537.53", Callback err = null)
#else
    public void Init(Callback cb = null, bool transparent = false, Callback err = null)
#endif

I highly recommend the Learn section of this website to learn the coding languages… they have some really good tutorials. But there are a lot of resources online, too, so you might try googling C# beginners guide or something similar.

Once you understand the syntax structure of both languages, converting code is merely tedious.

Those parameters are named parameters which is a feature of the C# compiler. You don’t have to use it. If you don’t use named parameters you have to pass the parameters in the right order. Default parameters (like in that method definition) in conjunction with positional parameters only work for the last parameters. So you can’t omit a parameter in between two other parameters. Named parameters do allow that since you specify which parameter you pass and the compiler doesn’t rely on the order in which you pass the parameters.

Your main problem is that you can’t omit the “transparent” parameter which is between the two delegate parameters.

I never really use UnityScript but i think this should work:

webViewObject.Init( function(msg:String) {}, false, function(err:String) {} );    

However if your platform is UNITY_EDITOR or UNITY_STANDALONE_OSX then you have to pass additional parameters in case you really need the “err” callback. Again you can’t omit parameters in between, only at the end. Since “err” is the last parameter you have to pass all parameters manually.

I don’t think that UnityScriupt supports named parameters, so your only option is to pass all parameters in the right order.