This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Coffee | |
def types | |
[ | |
"espresso", | |
"cappuccino", | |
"macchiato" | |
] | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"local/coffee" | |
) | |
func main() { | |
menu() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package coffee | |
func Types() []string { | |
types := []string{"espresso", "cappuccino", "macchiato"} | |
return types | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var array [SIZE]string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
array = [] | |
array[0] = "foo" | |
array << "bar" | |
puts array[0] #> foo | |
puts array[1] #> bar | |
array #> ["foo", "bar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const MAX_ARRAY_SIZE = 2 | |
var array [MAX_ARRAY_SIZE]string | |
array[0] = "foo" | |
array[1] = "bar" | |
fmt.Println(array[0]) | |
fmt.Println(array[1]) | |
fmt.Println(array) | |
// foo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
array := make([]string, SIZE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const MAX_ARRAY_SIZE = 2 | |
array := make([]string, MAX_ARRAY_SIZE) | |
array[0] = "foo" | |
array[1] = "bar" | |
fmt.Println(array[0]) | |
fmt.Println(array[1]) | |
fmt.Println(array) | |
// foo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
array := make([]string, 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
array := make([]string, 2, 3) | |
array[0] = "foo" | |
array[1] = "bar" | |
array[2] = "baz" | |
// oops, error |