Skip to content

Instantly share code, notes, and snippets.

@david50407
Created November 10, 2015 10:53
Show Gist options
  • Save david50407/dc029dbfa2ed2a32b50c to your computer and use it in GitHub Desktop.
Save david50407/dc029dbfa2ed2a32b50c to your computer and use it in GitHub Desktop.
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
$ > 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