📜  将数字的每个数字平方红宝石代码示例

📅  最后修改于: 2022-03-11 15:04:47.885000             🧑  作者: Mango

代码示例2
number = 12345
number.to_s.chars.map { |num| num.to_i ** 2 }.join.to_i
# convert number to string (.to_s), convert string to array (.chars)
# .map each array element to the result of a block call. 
# .join array into string & convert back to integer.