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

The when expression

The classic switch statement is supported in many languages, including C, C++, and Java, but it is rather restrictive. At the same time, the functional programming concept of pattern matching has become more mainstream. Kotlin blends the two, and offers when, a more powerful alternative to switch while not going quite as far as full pattern matching.

There are two forms of when. The first is similar to switch, accepting an argument, with a series of conditions, each of which is checked, in turn, against the value. The second is without an argument and is used as a replacement for a series of if...else conditions.

主站蜘蛛池模板: 呼图壁县| 永春县| 彭州市| 腾冲县| 开化县| 湘西| 湖州市| 新民市| 吐鲁番市| 宣汉县| 昌图县| 远安县| 门头沟区| 郯城县| 志丹县| 奉化市| 竹溪县| 大方县| 竹北市| 鄂托克旗| 新疆| 修文县| 社旗县| 平安县| 岑溪市| 安仁县| 赫章县| 宜都市| 丽水市| 河西区| 桃园县| 商南县| 仪陇县| 珠海市| 县级市| 长宁区| 南汇区| 巴林左旗| 和静县| 普宁市| 昭通市|