Sha256: 4ff9ad8adca3c5fe81cef88c79c698e052eeedac9d98715afc5568e0faab3894
Contents?: true
Size: 776 Bytes
Versions: 26
Compression:
Stored size: 776 Bytes
Contents
class Object # Tests to see if something has value. An object # is considered to have value if it is not nil? # and if it responds to #empty?, i snot. # def val? return false if nil? return false if empty? if respond_to?(:empty?) true end end # _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # =begin test require 'test/unit' class TCKernel < Test::Unit::TestCase def test_val_1 f = nil t = 1 assert( ! f.val? ) assert( t.val? ) end def test_val_2 f = [] t = [1] assert( ! f.val? ) assert( t.val? ) end def test_val_3 f = '' t = '1' assert( ! f.val? ) assert( t.val? ) end end =end
Version data entries
26 entries across 26 versions & 1 rubygems