You already know how a variadic function works with numbers. Let's write a code that contains a variadic parameter with a boolean type. You need to write a function that returns true if any of the arguments are true, and returns false if all of them are false. In the input, you get three logical values. You need to output the result that the function returns.
Variadic functions
Logical addition
Report a typo
Sample Input 1:
false true falseSample Output 1:
trueWrite a program in Go
package main
import "fmt"
func main() {
var a, b, c bool
fmt.Scan(&a, ?, ?)
fmt.Println(Any(?))
}
func Any(values ?) ? {
for _, v := range values {
if v {
return ?
}
}
return false
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.