小编Fur*_*kan的帖子

在 Kotlin 中使用列表或数组的范围

我试过了,但失败了。“范围”用于哪些情况?

var list = listOf(1,2,3,4,5)

它运作良好。但是下面的代码并没有像我想要的那样工作。为什么?

var list = listOf(1 .. 5)

可运行的程序是:https : //pl.kotl.in/c5256MZEC

range kotlin

2
推荐指数
1
解决办法
171
查看次数

高阶函数很复杂?

我已经阅读了很多文章,但仍有一些我难以理解的事情。我不明白的地方在哪里?我的问题在代码中。我希望我问对了。

fun main() {
    /*
    1- Is it argument or parameter in numbers{} block?
    where is it sent to the argument? why do we send "4" if it is parameter?
    Are all the functions I will write in (eg println) sent to the numbers function? But this HOF can 
    only take one parameter.
    */
    numbers {
        /*
        2-How does this know that he will work 3 times?
        According to the following 3 functions? Is there a for loop logic??
        */ …
Run Code Online (Sandbox Code Playgroud)

lambda higher-order-functions kotlin

0
推荐指数
1
解决办法
85
查看次数

标签 统计

kotlin ×2

higher-order-functions ×1

lambda ×1

range ×1