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.
假设我在 C# 中有一个字符串数组,我可以使用以下 LINQ 语句将此字符串数组转换为整数数组:
(new[] {"1", "2", "3"}).Select(x => int.parse(x))
有与此等效的Ruby吗?
更短的解决方案:
["1", "2", "3"].map(&:to_i)
不太确定Select在 C# 中是什么意思,但是将字符串数组转换为整数数组非常简单:["1", "2", "3"].map(&method(:Integer))
Select
["1", "2", "3"].map(&method(:Integer))