This file contains hidden or 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 first = 0 | |
| var second = 1 | |
| var result = 0 | |
| do { | |
| result = first + second | |
| first = second | |
| second = result | |
| println(result) | |
| } while result < 1000000000000 |
This file contains hidden or 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
| // for loop value range smaller then | |
| for i in 0..<10 { | |
| println(i) | |
| } | |
| println() | |
| // regular style for loop | |
| for var a = 0; a < 10; a++ { | |
| println(a) |
This file contains hidden or 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
| // Functions in Swift | |
| func say(name: String) -> String { | |
| return name | |
| } | |
| say("Hello World") | |
| // Multiple parameters |
This file contains hidden or 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
| // a & b & c are exactly the same | |
| // a is shorthand written | |
| // b is the long version | |
| // c is the type infered version | |
| var a: [Int] = [1, 2, 3, 4, 5] | |
| var b: Array<Int> = [1, 2, 3, 4, 5] | |
| var c: = [1, 2, 3, 4, 5] | |
| var a: [String: Int] = ["a": 1, "b": 2] |
This file contains hidden or 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
| kind: pipeline | |
| name: python27 | |
| steps: | |
| - name: test | |
| image: python:2.7-alpine3.9 | |
| commands: | |
| - pip install -e . | |
| - pip install -e .[tests] | |
| - pytest |
This file contains hidden or 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 yourpackage | |
| import "testing" | |
| func setup(t *testing.T) { | |
| t.Log("setup") | |
| } | |
| func teardown(t *testing.T) { | |
| t.Log("teardown") |
This file contains hidden or 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 yourpackage | |
| import ( | |
| "io/ioutil" | |
| "net/http" | |
| ) | |
| func GetData() ([]byte, error) { | |
| resp, err := http.Get("http://example.com/api/v1/examples") | |
| if err != nil { |
This file contains hidden or 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 yourpackage | |
| import ( | |
| "fmt" | |
| "io/ioutil" | |
| "net/http" | |
| ) | |
| type ApiClient struct { | |
| protocol string |
This file contains hidden or 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 yourpackage | |
| import ( | |
| "fmt" | |
| "log" | |
| "net/http" | |
| "net/http/httptest" | |
| "net/url" | |
| "testing" | |
| "time" |
This file contains hidden or 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 job | |
| type Job struct { | |
| client ApiClient | |
| } | |
| func NewJob(client ApiClient) FetchJob { | |
| return Job{client: client} | |
| } |
OlderNewer