Rubyã§assertããããã¯ã§æ¸ããããã«ãã¾ããã³ã¼ããè¦ãã°ãä¸ç®çç¶ã§ããEvernoteãæ´çãã¦ããåºã¦ãã¾ããããã®ãã¿ãã©ãã§ç¥ã£ããã ã£ããã æºåã§ãã module Assertions class AssertionError < StandardError end def assert(&block) yield or raise AssertionError end end blockã®å®è¡çµæãfalseã ã¨ãAssertionErrorãçºçããããã«ãªã£ã¦ãã¾ããã ã³ã¼ãä¸ã§assertãæ¸ãã¾ãã class Person include Assertions def initialize(name) assert { name != nil } @name = name end end Person.new(nil) #=> AssertionEr
{{#tags}}- {{label}}
{{/tags}}