Sha256: 6fcbae57492f6966a5a066b8af923dbbf840066dd0a458304b668d0705fdfb12

Contents?: true

Size: 570 Bytes

Versions: 4

Compression:

Stored size: 570 Bytes

Contents

class TestIf
  def test
    puts "OK" if true
    puts "NOT OK" if false
    puts "OK" unless false
    puts "NOT OK" unless true
    puts "OK" if true and true and (true or false) and (!false)

    puts "OK" if 5 < 6 and 6 < 7

    # test the "||" operator
    p(false || "a") # => "a"
    p(nil || "a")   # => "a"
    p(true || "a")  # => true
    p("b" || "a")   # => "b"

    # test the "&&" operator

    p(false && "a") # => false
    p(nil && "a")   # => nil
    p(true && "a")  # => "a"
    p("b" && "a")   # => "a"
  end

  def self.main
    new.test
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
superchris-rubyjs-0.8.2 test/test_if.rb
rubyjs-0.8.0 test/test_if.rb
rubyjs-0.7.1 test/test_if.rb
rubyjs-0.7.0 test/test_if.rb