gpt4 book ai didi

Ruby:检查字符串是否可以转换为整数

转载 作者:数据小太阳 更新时间:2023-10-29 06:45:28 29 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Test if a string is basically an integer in quotes using Ruby?

"1""one"

第一个字符串是一个数字,我可以只说 to_i 得到一个整数。
第二个字符串也是一个数字,但我不能直接调用 to_i 来获取所需的数字。

如何检查我是否可以使用 to_i 成功转换?

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com