:-) ๐Ÿ•

defined? function

July 04, 2019

  • NoMethodError ใ‚’ๅ›ž้ฟใ™ใ‚‹ใฎใซๅญ˜ๅœจใ‚’็ขบ่ชใ™ใ‚Œใฐใ„ใ„ใจๆ€ใฃใŸใ‘ใ‚Œใฉใ€ใใฎๆ™‚ใฏ defined? ใ‚’ๅˆฅใงไฝฟใ†ๅฟ…่ฆใŒใ‚ใ‚‹
  • ใ„ใ‚ใ„ใ‚ใชๆ›ธใๆ–นใŒใ‚ใ‚‹ใฎใฏ้›ฃใ—ใ„
# NoMethodError
if a.b.preset?
  a.b(c)
end
defined?(bacon)
# nil

Written by Keisuke Kan who lives and works in Japan building useful things. You should follow him on Twitter

ยฉ 2020, Built with Gatsby