They are the same in how they work. This is really a signal of intent. Personally, I would recommend a function in this case, which is a little contrary to intuition, so I will explain.
First rule: "are there any side effects?" If so, it should be a function.
: " O (1)?" ( , " ". , "?" ). , .
, - " " "?" , . , . , , -, . , ( "4" "abs" "-4" ). .
, Swift 3 abs (, Double.abs(4.0) (4.0).abs). , , , , .