Created
November 10, 2015 10:53
-
-
Save david50407/dc029dbfa2ed2a32b50c to your computer and use it in GitHub Desktop.
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 | |
@value = 0 | |
def initialize(v = 0, v2 = 10) | |
@value = v | |
@value2 = 10 | |
end | |
def value | |
@value | |
end | |
def value2 | |
@value2 | |
end | |
end | |
foos = [] of Foo | |
foos << Foo.new | |
foos << Foo.new(1, 200) | |
foos << Foo.new("string") | |
foos << Foo.new("string", "string") | |
foos << Foo.new(:symbol, 100_i64) | |
foos.each do |f| | |
puts f.value, f.value2 | |
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
$ > crystal tool context --cursor class_array_test.cr:25:23 class_array_test.cr | |
1 possible context found | |
| Expr | Type | | |
------------------------- | |
| foo | Foo | | |
| foos | Array(Foo) | | |
| f | Foo | | |
| f.value2 | Int32 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment