https://play.golang.org/p/8KtLSEtzcjr
var array = [...]int{0, 4:1, 2, 1:1}
Composite literals
| package main | |
| type T int | |
| type MV interface { | |
| mv(int) | |
| } | |
| type MP interface { | |
| mp(int) |
https://play.golang.org/p/8KtLSEtzcjr
var array = [...]int{0, 4:1, 2, 1:1}
Composite literals
| package main | |
| func Itoa(ival int) string { | |
| var buf []byte | |
| var r []byte | |
| var next int | |
| var right int | |
| for { | |
| if ival < 0 { |
| package main | |
| import ( | |
| "fmt" | |
| "image" | |
| "image/color" | |
| "image/png" | |
| "os" | |
| ) |
| <!DOCTYPE html> | |
| <!-- This is a port of "counter-vanilla" example without depending on Redux. --> | |
| <!-- Original is https://github.com/reduxjs/redux/blob/v4.0.5/examples/counter-vanilla/index.html --> | |
| <html> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Redux-like Counter</title> | |
| </head> | |
| <body> | |
| <h1>Redux-like Counter</h1> |
| <?php | |
| $my_json2 = '{"tax":2.03}'; | |
| $decoded = json_decode($my_json2, true); | |
| echo $decoded['tax'] . PHP_EOL; | |
| $tax_in_cents = round($decoded['tax'] * 100); | |
| $response = ['tax_cents' => intval($tax_in_cents)]; | |
| echo json_encode($response) . PHP_EOL; // => 203 |
| public class RocketLauncher { | |
| public boolean launch() { | |
| Rocket rocket = new Rocket(); | |
| rocket.addFuel(100); | |
| rocket.unlock(); | |
| boolean result = rocket.launch(); | |
| return result; | |
| } | |
| } |
| -- 0debugbuiltin.go -- | |
| package main | |
| // These functions are builtin in the 2gen compiler. | |
| func dumpInterface(x interface{}) { | |
| } | |
| func assertInterface(x interface{}) { |
| #!/bin/bash | |
| # | |
| # a tool to apply return type declarations to "setUp" and "tearDown" for PHPUnit7 | |
| # list target files by using GNU grep | |
| grep --files-with-matches -i -w -e setup -e teardown -r tests > /tmp/files | |
| # do substitution | |
| cat /tmp/files | xargs perl -pi -e 's/setUp\(\)$/setUp(): void/g' | |
| cat /tmp/files | xargs perl -pi -e 's/tearDown\(\)$/tearDown(): void/g' |
| package main | |
| import ( | |
| "fmt" | |
| "io/ioutil" | |
| "log" | |
| "net/http" | |
| ) | |
| func main() { |