Skip to content

Instantly share code, notes, and snippets.

View jjuliano's full-sized avatar

Joel Bryan Juliano jjuliano

View GitHub Profile
package main
import (
"fmt"
"sort"
)
func main() {
var script map[int]string
package main
import "fmt"
func main() {
basket(map[string]string{
"name": "apple",
"flavour": "It's a little sour and bitter, but mostly sweet, not at all salty, very juicy in general.",
}, "fruit")
}
package main
import "fmt"
func main() {
produce := map[string][]string{
"fruits": []string{"Apple", "Mango", "Orange", "Banana"},
"veggies": []string{"Cucumber", "Carrot", "Kale", "Broccoli"},
}
package main
import "fmt"
type produce struct {
name string
flavour string
kind string
}
package main
import "fmt"
type basket []map[string]string
func main() {
basket := new(basket)
basket.add_item(map[string]string{
class Basket
def initialize
@basket = []
end
def add_item(kind, **item)
@basket << item.merge({kind: kind})
puts "Entry #{item[:name]} created!"
puts
end
package main
import "fmt"
func basket(fruits ...string) {
for _, fruit := range fruits {
fmt.Printf("%s is in the basket\n", fruit)
}
}
func (receiverName receiverType) functionName(parameterName parameterType) {
// we can set the value of an _already initialised_ receiver type
// but we cannot modify the receiver type directly
receiverName = parameterName
// we can access the value of the _already initialised_ receiver type (getters)
fmt.Println(receiverName)
}
func (receiverName *receiverType) functionName(parameterName parameterType) {
// we can directly set the value of the receiver type (setter)
*receiverName = parameterName
// we can also access the value of the receiver type (getter)
fmt.Println(receiverName)
}
package main
import "fmt"
type basket []produce
type produce struct {
name string
flavour string
kind string
}