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
//Go | |
for { | |
// do something | |
} |
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
// go | |
num := 9 | |
if num < 0 { | |
fmt.Printf("%d is negative", num) | |
} else if num < 10 { | |
fmt.Printf("%d has 1 digit", num) | |
} else { | |
fmt.Printf("%d has multiple digits", num) | |
} |
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" | |
"time" | |
) | |
func f(from string) { | |
for i := 0; i < 3; i++ { | |
time.Sleep(1 * time.Millisecond) |
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
#ruby | |
str = `{"page": 1, "fruits": ["apple", "peach"]}` | |
JSON.parse(str) |
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
// Go | |
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
) | |
// Go | |
type response struct { |
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
#Ruby | |
hash = {apple: 5, lettuce: 7} | |
#encoding hash to json | |
json_data = hash.to_json | |
puts json_data |
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
// Go | |
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
) | |
func main() { |
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
#Ruby | |
class User | |
attr_accessor :user_name | |
def initialize(user_name, password) | |
@user_name = user_name | |
@password = password | |
end | |
def get_user_password |
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
// Go | |
type User struct { | |
Username string | |
password string | |
} | |
func (u User) GetPassword() string{ | |
return u.secretPassword() | |
} |
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
# Ruby | |
class Festival | |
def initialize(name, description) | |
@name = name | |
@description = description | |
end | |
def is_dashain? | |
if @name == "Dashain" | |
@description = "Let's fly kites." |
NewerOlder