当前位置:网站首页>Kotlin condition control
Kotlin condition control
2022-07-04 19:42:00 【AdleyTales】
fun main() {
val a = 12
val b = 5
var c: Int
var d: Int
if (a > b) {
c = 10000
} else {
c = 0
}
println("c: $c") // 10000
// 2 Similar to ternary operators
d = if (a > b) 20000 else 0
println("d: $d") // 20000
println("------")
// 3 IF The result of the expression is assigned to a variable
val sum = if (a > b) {
1000000
} else {
0
}
println(sum) // 1000000
// 4 Section
val g = 13
if (g in 1..18) {
println(" A minor ")
} else if (g > 18) {
println(" adult ")
}
// 5 when expression
// when Similar to other languages switch The operator
val x = 38
when(x){
0, 1 -> println(" Just born ")
in 1..18 -> println(" A minor ")
!in 20..28 -> println(" A minor 2")
else -> {
println(" Grown up ")
}
}
}
边栏推荐
- Shell programming core technology "four"
- How test engineers "attack the city" (Part 2)
- Some thoughts on whether the judgment point is located in the contour
- 【问题】druid报异常sql injection violation, part alway true condition not allow 解决方案
- kotlin 类和对象
- BCG 使用之CBCGPProgressDlgCtrl進度條使用
- Jetpack compose tutorial
- There are multiple divs in the large div, which are displayed on the same line. After overflow, scroll bars are generated without line breaks
- Cbcgpprogressdlg progress bar used by BCG
- 矩阵翻转(数组模拟)
猜你喜欢
node_ Exporter deployment
JVM系列之对象的创建
TCP两次挥手,你见过吗?那四次握手呢?
Pointnet/Pointnet++点云数据集处理并训练
多表操作-外连接查询
Pythagorean number law (any three numbers can meet the conditions of Pythagorean theorem)
C # use stopwatch to measure the running time of the program
Online sql to excel (xls/xlsx) tool
西门子HMI下载时提示缺少面板映像解决方案
黑马程序员-软件测试--08阶段2-linux和数据库-23-30-进程端口相关,修改文件权限,端口号信息的获取,程序和进程相关操作,linux命令案例
随机推荐
黑马程序员-软件测试--07阶段2-linux和数据库-09-24-linux命令学习步骤,通配符,绝对路径,相对路径,文件和目录常用命令,文件内容相关操作,查看日志文件,ping命令使用,
Add namespace declaration
Online sql to excel (xls/xlsx) tool
在线文本行固定长度填充工具
Master the use of auto analyze in data warehouse
Shell programming core technology "four"
指定输出的字符集
MySQL数据库基本操作-DDL | 黑马程序员
大div中有多个div,这些div在同一行显示,溢出后产生滚动条而不换行
HDU 6440 2018中国大学生程序设计网络选拔赛
Oracle with as ora-00903: invalid table name multi report error
Shell programming core technology "three"
Functional interface
SSRS筛选器的IN运算(即包含于)用法
Educational Codeforces Round 22 E. Army Creation
需求开发思考
Lm10 cosine wave homeopathic grid strategy
欧拉函数
数据集划分
C# 使用StopWatch测量程序运行时间