小编tru*_*yer的帖子

Kotin 类型不匹配:推断类型是 Int?但 Int 是预期的

我试图获取 Kotlin 中两个数字之间的最大数字,但我不断收到类型不匹配错误。我尝试使用 Int?.toInt() 它不起作用。

我也尝试过使用 Int!作为 None Null 值的双重感叹号,它也不起作用。

fun main(args: Array<String>){

    val nums = arrayOf(8, 5, 6, 8, 9)
    var sorted = arrayOfNulls<Int>(nums.size)

    // manually set 2 values
    sorted[0] = nums[0]
    sorted[1] = nums[1]

    for(i in 1 until nums.size-1){
        val value = sorted[i - 1]
        val max = maxOf(value!!, nums[i]) // This line throws Null pointer exception: error: type mismatch: inferred type is Int? but Int was expected
        // do something with max
    }

    println(sorted)
}
Run Code Online (Sandbox Code Playgroud)

arrays kotlin

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

如何为 PostgreSQL 14 设置 PostgreSQL 二进制路径

我正在阅读本教程:PostgreSQL:https://dba.stackexchange.com/questions/149169/binary-path-in-the-pgadmin-preferences

为了设置 PostgreSQL 二进制路径,我查看了 PgAdmin 上的首选项,看到所有版本的 PostgreSQL 都更新了二进制路径,除了我实际使用的 PostgreSQL 14 之外。

请问我应该将二进制路径更新到哪里?

我已经添加了屏幕截图

在此输入图像描述

pgadmin-4

6
推荐指数
1
解决办法
1万
查看次数

UITableView 上的 iOS didSelectRowAt 行不起作用

我正在尝试跟进 CodePath 上的本教程:访问https://guides.codepath.com/ios/Search-Bar-Guide#cancelling-out-of-search-and-hiding-keyboard

我创建了一个 SearchViewController 来搜索,但didSelectRowAt不起作用

这是我的代码如下:

class SearchViewController: UIViewController, UITableViewDataSource, UISearchBarDelegate {
    @IBOutlet weak var tableView: UITableView!
    @IBOutlet weak var searchBar: UISearchBar!

    let data = ["New York, NY", "Los Angeles, CA", "Chicago, IL", "Houston, TX",
                "Philadelphia, PA", "Phoenix, AZ", "San Diego, CA", "San Antonio, TX",
                "Dallas, TX", "Detroit, MI", "San Jose, CA", "Indianapolis, IN",
                "Jacksonville, FL", "San Francisco, CA", "Columbus, OH", "Austin, TX",
                "Memphis, TN", "Baltimore, MD", "Charlotte, ND", "Fort Worth, TX"]

    var filteredData: [String]!

    override …
Run Code Online (Sandbox Code Playgroud)

uitableview didselectrowatindexpath ios swift

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