We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e2de2e1 commit 4833c8bCopy full SHA for 4833c8b
structural/decorate.go
@@ -0,0 +1,28 @@
1
+package main
2
+
3
+type Object func(int) int
4
5
+func LogDecorate(fn Object) Object {
6
+ return func(n int) int {
7
+ log.Println("Starting the execution with the integer", n)
8
9
+ result := fn(n)
10
11
+ log.Println("Execution is completed with the result", result)
12
13
+ return result
14
+ }
15
+}
16
17
+func Double(n int) int {
18
+ return n * 2
19
20
21
+func main(){
22
+ f := LogDecorate(Double)
23
+ f(5)
24
25
26
27
+// Starting execution with the integer 5
28
+// Execution is completed with the result 10
0 commit comments