Add block type hints

This commit is contained in:
Anton Vakhrushev 2019-10-10 16:25:22 +03:00
parent 55f9bad188
commit f03a13ce66

View File

@ -20,9 +20,7 @@ module Game
property data : DataArray property data : DataArray
def initialize(rows : Int32, cols : Int32) def initialize(@rows : Int32, @cols : Int32)
@rows = rows
@cols = cols
@data = DataArray.new @rows @data = DataArray.new @rows
@rows.times do |row_index| @rows.times do |row_index|
tile_row = TileRow.new @cols tile_row = TileRow.new @cols
@ -56,7 +54,7 @@ module Game
@data[point.x][point.y] = tile @data[point.x][point.y] = tile
end end
def tiles def tiles(&block : Point, Tile -> _)
(0...@rows).each do |x| (0...@rows).each do |x|
(0...@cols).each do |y| (0...@cols).each do |y|
point = Point.new(x, y) point = Point.new(x, y)
@ -66,7 +64,7 @@ module Game
end end
end end
def nearest_tile(point : Point, &block) : Tile | Nil def nearest_tile(point : Point, &block : Tile -> Bool) : Tile | Nil
seek_tile = nil seek_tile = nil
min_dist = Int32::MAX min_dist = Int32::MAX
tiles do |tile_point, tile| tiles do |tile_point, tile|