当前位置:网站首页>Kotlin function
Kotlin function
2022-07-05 12:42:00 【Curious rookie】
One 、 Function definition
/*
keyword Function name Parameter type return type
↓ ↓ ↓ ↓ */
fun helloFunction(name: String): String {
return "Hello $name !"
}/* ↑
Inside the curly brackets is : The body of the function
*/Abbreviation
fun helloFunction(name: String): String = "Hello $name !"fun helloFunction(name: String) = "Hello $name !"Two 、 Function call
helloFunction("Kotlin")helloFunction(name = "Kotlin")3、 ... and 、 Function default parameters
fun createUser(
name: String,
age: Int,
gender: Int = 1,
friendCount: Int = 0,
feedCount: Int = 0,
likeCount: Long = 0L,
commentCount: Int = 0
) {
//..
}
fun createUser(
name: String,
age: Int,
gender: Int = 1,
friendCount: Int = 0,
feedCount: Int = 0,
likeCount: Long = 0L,
commentCount: Int = 0
) {
//..
}Parameters with default values can be omitted
createUser(
name = "Tom",
age = 30,
commentCount = 3285
)边栏推荐
- MySQL regular expression
- ZABBIX agent2 monitors mongodb nodes, clusters and templates (official blog)
- Rasa Chat Robot Tutorial (translation) (1)
- Pytoch through datasets Imagefolder loads datasets directly from files
- Differences between IPv6 and IPv4 three departments including the office of network information technology promote IPv6 scale deployment
- Resnet+attention project complete code learning
- How can beginners learn flutter efficiently?
- Deep discussion on the decoding of sent protocol
- Full text search of MySQL
- [hdu 2096] Xiaoming a+b
猜你喜欢

Resnet18 actual battle Baoke dream spirit

ZABBIX customized monitoring disk IO performance

Add a new cloud disk to Huawei virtual machine

How can beginners learn flutter efficiently?

Pytoch monolayer bidirectional_ LSTM implements MNIST and fashionmnist data classification

Understand redis persistence mechanism in one article

VoneDAO破解组织发展效能难题

Implementing Yang Hui triangle with cyclic queue C language

在家庭智能照明中应用的测距传感芯片4530A

Pytoch implements tf Functions of the gather() function
随机推荐
Seven polymorphisms
ActiveMQ installation and deployment simple configuration (personal test)
About LDA model
Differences between IPv6 and IPv4 three departments including the office of network information technology promote IPv6 scale deployment
Kotlin流程控制、循环
Instance + source code = see through 128 traps
Learn JVM garbage collection 05 - root node enumeration, security points, and security zones (hotspot)
Redis clean cache
Annotation problem and hidden Markov model
Detailed steps for upgrading window mysql5.5 to 5.7.36
[figure neural network] GNN from entry to mastery
struct MySQL
Pytorch two-layer loop to realize the segmentation of large pictures
Take you hand in hand to develop a service monitoring component
Learn garbage collection 01 of JVM -- garbage collection for the first time and life and death judgment
MySQL function
Read and understand the rendering mechanism and principle of flutter's three trees
Array cyclic shift problem
Keras implements verification code identification
Kotlin函数