Skip to content
  • Albert Astals Cid's avatar
    Introduce Object::getNumWithDefaultValue · 647274f1
    Albert Astals Cid authored
    Is like getNum but instead of asserting if Object is not a num it
    returns the given default value
    
    I find it much easier to read
        rect->x1 = obj1.arrayGet(0).getNumWithDefaultValue(0);
    than
        (obj2 = obj1.arrayGet(0), obj2.isNum() ? rect->x1 = obj2.getNum() : rect->x1 = 0);
    
    On top of it has the benefit of being slightly faster
    647274f1