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
| macro ruby_class(name) | |
| _class = Ruby::Class.new({{name.id.stringify}}) | |
| {{yield}} | |
| end | |
| macro ruby_def(name, &block) | |
| _class.def {{name}}, {{block.args.length}}, | |
| ->(self : LibRuby::VALUE, {{*block.args.map { |arg| "#{arg} : LibRuby::VALUE".id } }}) do | |
| {{yield}} | |
| 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 StringPool | |
| getter length | |
| def initialize | |
| @buckets = Array(Array(String)?).new(11, nil) | |
| @length = 0 | |
| end | |
| def get(str : UInt8*, len) | |
| rehash if @length > 5 * @buckets.length |
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 Crystal | |
| module Config | |
| PATH = {{ env("CRYSTAL_CONFIG_PATH") || "" }} | |
| VERSION = {{ env("CRYSTAL_CONFIG_VERSION") || `(git describe --tags --long 2>/dev/null)` }} | |
| 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
| We are very happy to announce the release of version 0.5.0 of Crystal! | |
| For those of you who couldn't install Crystal so far, or had troubles installing it, we have good news: we now provide .deb, .rpm and .tar.gz packages for 64 bits linux architectures directly on the releases pages. We tries those in a very old Centos version, as well as in ArchLinux and Debian. The executable has all the necessaries libraries statically linked so there won't be any more problems with incompatible or missing shared libraries [*]. And it also has LLVM statically linked: the only executable you need to have in your system is cc. | |
| For Mac users the install procedure is the same as before: | |
| brew tap manastech/crystal | |
| brew update | |
| brew install crystal |
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) |
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
| ; 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
| 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
| 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 | |
| property x | |
| property y | |
| property z | |
| property w | |
| def initialize | |
| end | |
| def dup |