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
| import scala.util.Random | |
| object Gist extends App { | |
| val languages = List("Java", "Scala", "Clojure") | |
| // get a random element from languages | |
| val randomLanguage = language(new Random().nextInt(languages.length)) | |
| println(randomLanguage) | |
| } |
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
| class Clock { | |
| def tick(): Unit = { | |
| while(true) { | |
| printf("\r%s", new SimpleDateFormat("HH:mm:ss").format(new Date())) | |
| Thread.sleep(1000) | |
| } | |
| } | |
| } | |
| object Clock extends App { |
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
| class Hello | |
| { | |
| public static void Main(string[] args) | |
| { | |
| while (true) | |
| { | |
| Thread.Sleep(1000 * 60 * 30); | |
| UpdateFunction(); | |
| } | |
| } |
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
| <?php | |
| namespace Cat; | |
| class Cat | |
| { | |
| private $name; | |
| public function __construct($name) | |
| { |
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
| // ES6 way | |
| class Dog { | |
| constructor(name) { | |
| this.name = name; | |
| } | |
| bark() { | |
| console.log(`${this.name} goes bark!`); | |
| } | |
| } |
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
| class Dog | |
| { | |
| public string Name { get; set; } | |
| private static int DogCount = 0; | |
| public Dog(string name) | |
| { | |
| this.Name = name; | |
| DogCount += 1; |
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
| <?php | |
| namespace Dog\App; | |
| use Dog\Dog; | |
| $beethoven = new Dog("Beethoven"); | |
| $beethoven->bark(); |
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
| // ES6 | |
| class Dog { | |
| constructor(name) { | |
| this.name = name; | |
| } | |
| bark() { | |
| alert("Bark!"); | |
| } |
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 cats = require('./cats.js'); | |
| cats.meow(); // prints "Meow!" | |
| //in python, it's | |
| import cats | |
| cats.meow() |
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
| // in terminal, I run 'npm install cats' | |
| // in my js file | |
| var cats = require('cats'); | |
| cats.meow(); |