我试图获取 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) 我正在阅读本教程:PostgreSQL:https://dba.stackexchange.com/questions/149169/binary-path-in-the-pgadmin-preferences
为了设置 PostgreSQL 二进制路径,我查看了 PgAdmin 上的首选项,看到所有版本的 PostgreSQL 都更新了二进制路径,除了我实际使用的 PostgreSQL 14 之外。
请问我应该将二进制路径更新到哪里?
我已经添加了屏幕截图
我正在尝试跟进 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)