Skip to content

Instantly share code, notes, and snippets.

View mahdyadi's full-sized avatar

Drianka Mahdy Adimas mahdyadi

  • East Jakarta, Indonesia
View GitHub Profile
package main
import (
"YOUR_PACKAGE_NAME/simple-cli/cmd"
)
func main() {
cmd.Execute()
}
package cmd
import (
"fmt"
"os"
"github.com/spf13/cobra"
)
var rootCmd = &cobra.Command{
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
var helloCmd = &cobra.Command{
Use: "hello",
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
var name string
var helloCmd = &cobra.Command{
...
public Game nextTick() {
HashMap<Cell, Integer> updateMap = new HashMap<Cell, Integer>();
for (Cell livingCell : this.cells) {
for (Cell neighbouringCell : livingCell.neighbours()) {
int currentCount = updateMap.getOrDefault(neighbouringCell, 0);
currentCount++;
updateMap.put(neighbouringCell, currentCount);
}
}
import UIKit
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
var navigationController: UINavigationController?
func scene(_ scene: UIScene,
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions) {
fun operate(subject: String, action: String.()->String) {
val acted = subject.action()
println(acted)
}
operate("foo"){
"$this bar"
} // foo bar
fun operate(subject: String, action: (String) -> String) {
val acted = action(subject)
println(acted)
}
operate("foo"){
"$it bar"
} //foo bar