Skip to main content
Commonmark migration
Source Link

#Swift

Swift

Swift allows for custom operators, this one still lets any other two numbers be added as you'd expect but if both arguments are 2 it will return 5.

func +(l:Int, r:Int) -> Int {
    var a = -r - l
    if l == 2 && r == 2 {--a}
    return -a 
}

print(2+2)

#Swift

Swift allows for custom operators, this one still lets any other two numbers be added as you'd expect but if both arguments are 2 it will return 5.

func +(l:Int, r:Int) -> Int {
    var a = -r - l
    if l == 2 && r == 2 {--a}
    return -a 
}

print(2+2)

Swift

Swift allows for custom operators, this one still lets any other two numbers be added as you'd expect but if both arguments are 2 it will return 5.

func +(l:Int, r:Int) -> Int {
    var a = -r - l
    if l == 2 && r == 2 {--a}
    return -a 
}

print(2+2)
deleted 3 characters in body
Source Link
cat
  • 5.9k
  • 2
  • 26
  • 44

Swift #Swift

Swift allows for custom operators, this one still lets any other two numbers be added as you'd expect but if both arguments are 2 it will return 5.

func +(l:Int, r:Int) -> Int {
    var a = -r - l
    if l == 2 && r == 2 {--a}
    return -a 
}

print(2+2)

Swift

Swift allows for custom operators, this one still lets any other two numbers be added as you'd expect but if both arguments are 2 it will return 5.

func +(l:Int, r:Int) -> Int {
    var a = -r - l
    if l == 2 && r == 2 {--a}
    return -a 
}

print(2+2)

#Swift

Swift allows for custom operators, this one still lets any other two numbers be added as you'd expect but if both arguments are 2 it will return 5.

func +(l:Int, r:Int) -> Int {
    var a = -r - l
    if l == 2 && r == 2 {--a}
    return -a 
}

print(2+2)
Source Link

Swift

Swift allows for custom operators, this one still lets any other two numbers be added as you'd expect but if both arguments are 2 it will return 5.

func +(l:Int, r:Int) -> Int {
    var a = -r - l
    if l == 2 && r == 2 {--a}
    return -a 
}

print(2+2)