Home
Muhammad Farag
Cancel

Ruby Conditionals: if, else, elseif and unless

There is the if statement similar to any other language you came from something_evil_lurking_in_the_dark = false if something_evil_lurking_in_the_dark puts "Run away!" end Now, let’s negate t...

Interfaces

There is no inheritance in Go, but there are interfaces! Interfaces has methods and any type having the same methods satisfies that interface. In that sense, that type is an instance of that interf...

Functions

Functions in Go are first class citizens. Function may return one or more arguments. They may take a function as an argument. We cover these topics here. We take a look at variadic functions in Go,...

Pimp My Library Pattern

Pimp my Library is a term coined by Martin Odersky explaining how Scala gives you the option of enriching types that you might not own. It comes to mined when you think about how methods can only h...

Methods

Let’s create a simple type, account which has one field money, we will create a one method add which will add some money to the account. type account struct { money int } func (a account) add(am...

Error Handling and Recovery

Go Functions may have multiple return values, by convention the last result is an error indicator or an error. An error indicator is a boolean that will evaluate to true if there is no errors. fun...

Collections

Go collections is very easy to learn. We have arrays and its close cousin slices. Then there are maps and that’s it. You can form a set using map keys as values. We will see how to create each of t...

Commandline Arguments and Flags

Go has a different way compared to languages such as Java, Scala and C in handling commandline arguments and flags. There are built in utility to generate commandline help message and assign defaul...

Type, Struct, Type Embedding and Constants

type is not a type alias, which is different than Scala for an example. The new type is not compatible, assignable or comparable to the original type. In my mind this is better than type aliasing b...