Go Methods Increment-Decrement operators as arguments in Methods

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

Though Go supports ++ and -- operators and the behaviour is found to be almost similar to c/c++, variables with such operators cannot be passed as argument to function.

    package main

    import (
        "fmt"
    )
    
    func abcd(a int, b int) {
     fmt.Println(a," ",b)
    }
    func main() {
        a:=5
        abcd(a++,++a)
    }

Output: syntax error: unexpected ++, expecting comma or )



Got any Go Question?