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
| module Moo | |
| # Moo expects `foo` to return an Int32 | |
| abstract def foo : Int32 | |
| # `bar` adds 1 to it | |
| def bar : Int32 | |
| foo + 1 | |
| end | |
| # And maybe it provides other methods... |
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 LinkedList(T) | |
| include Enumerable | |
| class Node(T) | |
| property :next | |
| property :data | |
| def initialize(@data : T, @next = nil) | |
| end | |
| end |
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 HtmlBuilder | |
| def initialize | |
| @str = StringBuilder.new | |
| end | |
| def build | |
| self.yield | |
| @str.to_s | |
| end |
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 Object | |
| def self.size | |
| base = Pointer(self).null | |
| (base + 1).address - base.address | |
| end | |
| end | |
| struct Foo | |
| def initialize(@x, @y, @z) | |
| end |
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 Foo | |
| property x | |
| property y | |
| property z | |
| property w | |
| def initialize | |
| end | |
| def dup |
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
| type = :info | |
| time = Time.now | |
| 2_000_000.times do | |
| msg = case type | |
| when :success then 'alert-success' | |
| when :error then 'alert-danger' | |
| when :warn then 'alert-warning' | |
| when :info then 'alert-info' | |
| end |
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 Foo | |
| def initialize(x : Number) | |
| puts "#{x} is a number!" | |
| end | |
| def initialize(x : String) | |
| puts "#{x} is a string!" | |
| end | |
| end |
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
| ; ModuleID = 'foo.ll' | |
| target triple = "x86_64-apple-darwin12.5.0" | |
| %String = type { i32, i32, i8 } | |
| %"{Int32, Int32, Int32}" = type { i32, i32, i32 } | |
| @symbol_table = global [0 x %String*] zeroinitializer | |
| ; Function Attrs: nounwind readnone | |
| define i32 @__crystal_main(i32 %argc, i8** nocapture %argv) #0 { |
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
| def self.read_keypress | |
| case C.getchar | |
| when 'a' | |
| :left | |
| when 's' | |
| :down | |
| when 'd' | |
| :right | |
| when 'w' | |
| :up |
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 StopIteration < Exception | |
| def initialize | |
| super("StopIteration") | |
| end | |
| end | |
| module Iterator(T) | |
| include Enumerable(T) | |
| def map(&func : T -> U) |
OlderNewer