Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有
val s = "123" val r = "a123h"
如何检查是否s可以解析为有效整数?
s
to-int包中的签名core是
to-int
core
public lostanza defn to-int (s:ref<String>) -> ref<False|Int>
所以你需要:
defn is-int? (s: String) -> True|False : to-int(s) is Int
注意:除了十进制之外,还to-int接受十六进制0x...、八进制0o... 和二进制字符串表示。0b...
0x...
0o...
0b...