当前位置:网站首页>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
)边栏推荐
- Leetcode-1. Sum of two numbers (Application of hash table)
- How to recover the information server and how to recover the server data [easy to understand]
- Full text search of MySQL
- struct MySQL
- Redis highly available slice cluster
- Master-slave mode of redis cluster
- JDBC -- use JDBC connection to operate MySQL database
- Yum only downloads the RPM package of the software to the specified directory without installing it
- Principle of universal gbase high availability synchronization tool in Nanjing University
- 激动人心!2022开放原子全球开源峰会报名火热开启!
猜你喜欢

JDBC exercise - query data encapsulated into object return & simple login demo

Add a new cloud disk to Huawei virtual machine

Knowledge representation (KR)

Volatile instruction rearrangement and why instruction rearrangement is prohibited

ActiveMQ installation and deployment simple configuration (personal test)
A guide to threaded and asynchronous UI development in the "quick start fluent Development Series tutorials"

MySQL transaction

Iterator details in list... Interview pits

前几年外包干了四年,秋招感觉人生就这样了..

Redis clean cache
随机推荐
II. Data type
Learn the memory management of JVM 02 - memory allocation of JVM
How can labels/legends be added for all chart types in chart. js (chartjs.org)?
MySQL multi table operation
The evolution of mobile cross platform technology
MySQL regular expression
The relationship between the size change of characteristic graph and various parameters before and after DL convolution operation
MySQL stored procedure
Docker configures redis and redis clusters
Pytoch counts the number of the same elements in the tensor
Learn garbage collection 01 of JVM -- garbage collection for the first time and life and death judgment
Get the variable address of structure member in C language
Learn the garbage collector of JVM -- a brief introduction to Shenandoah collector
Get all stock data of big a
Summary of C language learning problems (VS)
Learn the memory management of JVM 03 - Method area and meta space of JVM
Handwriting blocking queue: condition + lock
How does MySQL execute an SQL statement?
Distributed solution - distributed lock solution - redis based distributed lock implementation
Solution to order timeout unpaid