当前位置:网站首页>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
)边栏推荐
- Kotlin变量
- How does MySQL execute an SQL statement?
- Learn JVM garbage collection 02 - a brief introduction to the reference and recycling method area
- A guide to threaded and asynchronous UI development in the "quick start fluent Development Series tutorials"
- Flutter2 heavy release supports web and desktop applications
- MySQL function
- Just a coincidence? The mysterious technology of apple ios16 is actually the same as that of Chinese enterprises five years ago!
- Cypher syntax of neo4j graph database
- Correct opening method of redis distributed lock
- GPS数据格式转换[通俗易懂]
猜你喜欢

Detailed steps for upgrading window mysql5.5 to 5.7.36

Anaconda creates a virtual environment and installs pytorch

Redis's memory elimination mechanism, read this article is enough.

Pytoch uses torchnet Classerrormeter in meter

从39个kaggle竞赛中总结出来的图像分割的Tips和Tricks

UNIX socket advanced learning diary - advanced i/o functions

Resnet+attention project complete code learning

Distributed cache architecture - cache avalanche & penetration & hit rate

Redis clean cache

MySQL storage engine
随机推荐
Implementing Yang Hui triangle with cyclic queue C language
Average lookup length when hash table lookup fails
The relationship between the size change of characteristic graph and various parameters before and after DL convolution operation
Pytoch implements tf Functions of the gather() function
前几年外包干了四年,秋招感觉人生就这样了..
Pytoch monolayer bidirectional_ LSTM implements MNIST and fashionmnist data classification
Kotlin变量
Leetcode-1. Sum of two numbers (Application of hash table)
Pytoch through datasets Imagefolder loads datasets directly from files
GNN(pytorch-geometric)
Understand kotlin from the perspective of an architect
Neural network of PRML reading notes (1)
Learn memory management of JVM 01 - first memory
Instance + source code = see through 128 traps
Get the variable address of structure member in C language
Master the new features of fluent 2.10
Redis clean cache
Get all stock data of big a
POJ-2499 Binary Tree
Get data from the database when using JMeter for database assertion