Исходники и презентации
This commit is contained in:
19
lessons/functions/imperative_declarative/main.go
Normal file
19
lessons/functions/imperative_declarative/main.go
Normal file
@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
func filterEvenNumbers(numbers []int) []int {
|
||||
return nil // implemented
|
||||
}
|
||||
|
||||
func main() {
|
||||
// imperative way
|
||||
var imperative []int
|
||||
for _, number := range []int{1, 2, 3, 4, 5} {
|
||||
if number%2 != 0 {
|
||||
imperative = append(imperative, number)
|
||||
}
|
||||
}
|
||||
|
||||
// declarative way
|
||||
declarative := filterEvenNumbers([]int{1, 2, 3, 4, 5})
|
||||
_ = declarative
|
||||
}
|
||||
Reference in New Issue
Block a user