Ruby syntax to avoid nil input being returned as zero

前端 未结 0 1754
生来不讨喜
生来不讨喜 2021-01-29 02:16

a Rails application has a sanitizing method

def mobile=(value)
  super(value.to_s.gsub(/\\s+/, "").to_i) unless value.nil?
end

Yet, whe

相关标签:
回答
  • 消灭零回复
提交回复
热议问题