david50407
11/10/2015 - 10:53 AM

new_gist_file.rb

 $ > 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    |
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