Variadic Function

A variadic function accept varying numbers of arguments. To declare a variadic function, the type of of the final parameter is preceded by an ellipsis, “…” …int ellipsis defined a function can be called with any number of arguments of this type vals is []int slice, can be access this slice using index or for..range

Methods with Struct

The Point struct type has two fields, x and y of float64 A method is defined with use of the keyword “func” just like a definition of the function. Just after func keyword, the defined fields of struct used in the body of code of the function as a receiver. It takes a variable of… Continue reading Methods with Struct

Function closures

Go functions may be closures. A closure is a function value that references variables from outside its body. The function may access and assign to the referenced variables; in this sense the function is “bound” to the variables

Memoization Technique (Fibonacci)

Let’s utilize a memoization technique to speed up our Fibonacci calculation. Memoization is an optimization technique used to increase performance by storing the results of expensive function calls and returning the cached result when the same input occurs again.