官术网_书友最值得收藏!

How it works...

We've declared a default value for the initialSpeed parameter, equal to 0. Once we have a default value assigned, the initialSpeed parameter becomes an optional one. We can now omit it while invoking the function, as shown in the following example:

val displacement = calculateDisplacement(acceleration = 9.81f, duration = 1000)

Note that, if we are omitting some of the parameters and using their default values, we have to specify the values of the other parameters together with their names explicitly. This allows the compiler to map the values to the specific parameters. Of course, we are able to override the default value using the standard way:

val displacement = calculateDisplacement(10f, 9.81f, 1000)
主站蜘蛛池模板: 宝鸡市| 勃利县| 太仆寺旗| 万载县| 南投县| 长武县| 汉川市| 台山市| 寿阳县| 遂平县| 湾仔区| 明溪县| 神木县| 大石桥市| 南安市| 枣庄市| 永康市| 寿阳县| 新竹市| 柏乡县| 镶黄旗| 昌宁县| 永清县| 托克逊县| 军事| 怀来县| 垣曲县| 阆中市| 成武县| 筠连县| 华坪县| 安吉县| 朝阳区| 瓦房店市| 富源县| 时尚| 舟曲县| 璧山县| 芦山县| 沁水县| 临朐县|