1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

v.util: add an iabs(x) helper (#9172)

This commit is contained in:
zakuro
2021-03-07 18:24:05 +09:00
committed by GitHub
parent 4c7b6ce2fd
commit 45d51c76da
3 changed files with 7 additions and 6 deletions

View File

@@ -363,6 +363,11 @@ pub fn imax(a int, b int) int {
return if a > b { a } else { b }
}
[inline]
pub fn iabs(v int) int {
return if v > 0 { v } else { -v }
}
pub fn replace_op(s string) string {
if s.len == 1 {
last_char := s[s.len - 1]