27 ms·
I'm not sure this is the reason, but function types look better if you put the return type after the parameter types. Compare C to Kotlin: float (* f)(int)
by rovolo 7y ago
I'm not sure this is the reason, but function types look better if you put the return type after the parameter types. Compare C to Kotlin:
float (* f)(int);
val f : (int) -> float;
float[] (* map)(int[], float (*)(int));
val map : (int[], (int) -> float) -> float[]
You could put the return type before the function, but then the type will look inconsistent with the function declaration:
float[] map(int[] arr, (int) -> float f)
fun map(arr : int[], f : (int) -> float) : float[]
So if you're passing functions around, it tends to look nicer if you always put the type after the variable/argument/function