Logical operators

 

Here is the code used in this lesson:

 

//OPERATORS

//1) SUM (+)

RuleContext sum {
    Rule rule {
        Integer a = 5
        Double b = 5.5
        Integer c = a + b
        Double d = a + b
    }
}

//2) CONCATENATION (+)

RuleContext concatenation {
    Rule rule {
        String a = "hello"
        Integer b = 4
        Double c = 5.5
        Bool d = true
        Date date = Date()
        
        String e = a + b
        e = a + c
        e = a + date
        e = a + d
    }
}

//3) SUBTRACTION (-)

RuleContext subtraction {
    Rule rule {
        Integer a = 5
        Double b = 5.5
        Integer c = a - b
        Double d = a - b
    }
}

//4) NEGATIVE SIGN (-)

RuleContext negative {
    Rule rule {
        Integer a = 1
        Double b = -2.4
        Integer c = -a
        Double d = -b
        Double e = -a
        Integer f = -b
    }
}

//5) MULTIPLICATION (*)

RuleContext multiplication {
    Rule rule {
        Integer a = 5
        Double b = 5.5
        Integer c = a * b
        Double d = a * b
    }
}

//6) ASSIGNMENT (=)

RuleContext assignment {
    Rule rule {
        Location loc = Location()
        Location loc1 = loc
        
        Integer a = 5
        Double b = a
    }
}

//7) EQUALITY (==)

RuleContext equality {
    Rule rule {
        Integer a = 5
        Double b = 5.5
        Bool c = a == b // false
        
        Location loc = Location()
        Location loc1 = Location()
        Bool d = loc == loc1 // false
        
        Location loc2 = loc1
        Bool e = loc1 == loc2 // true
    }
}

> Next