0
点赞
收藏
分享

微信扫一扫

Kotlin Example

高子歌 2022-02-08 阅读 64

Introduction

Hello Word

Kotlin code is usually defined in packages. Package specification is optional: If you don’t specify a package in a source file, its content goes to the default package.
An entry point to a Kotlin application is the main function. Since Kotlin 1.3, you can declare main without any parameters. The return type is not specified, which means that the function returns nothing.
println writes a line to the standard output. It is imported implicitly. Also note that semicolons are optional.

Functions

Infix Functions

Member functions and extensions with a single parameter can be turned into infix functions.

fun main() {

  infix fun Int.times(str: String) = str.repeat(this)        // 1
  println(2 times "Bye ")                                    // 2

  val pair = "Ferra
举报

相关推荐

example

Example

Classification Example

addCatch example

example.com

Example2

0 条评论