samples/04_physics_and_collisions/05_box_collision_2/app/main.rb
def attempt_load_world_from_file
    return if state.world # return if the world collection is already populated
    state.world ||= [] # initialized as an empty collection
    exported_world = gtk.read_file(MAP_FILE_PATH) # reads the file using the path mentioned at top of code
    return unless exported_world # return unless the file read was successful
    state.world = exported_world.each_line.map do |l| # perform action on each line of exported_world
        l.split(',').map(&:to_i) # calls split using ',' as a delimiter, and invokes .map on the collection,
                                 # calling to_i (converts to integers) on each element
    end
  end
# Loads the world collection by reading from the map.txt file in the app folder
Loads the world collection by reading from the map.txt file in the app folder
Loads the world collection by reading from the map . txt file in the app folder
def attempt_load_world_from_file
    return if state.world 
    state.world ||= [] 
    exported_world = gtk.read_file(MAP_FILE_PATH) 
    return unless exported_world 
    state.world = exported_world.each_line.map do |l| 
        l.split(',').map(&:to_i) 
    end
  end
def attempt_load_world_from_file return if state . world state . world ||= [ ] exported_world = gtk . read_file ( MAP_FILE_PATH ) return unless exported_world state . world = exported_world . each_line . map do | l | l . split ( ',' ) . map ( & :to_i ) end end
Loads the world collection by reading from the map.txt file in the app folder
Loads the world collection by reading from the map . txt file in the app folder
# return if the world collection is already populated # initialized as an empty collection # reads the file using the path mentioned at top of code # return unless the file read was successful # perform action on each line of exported_world # calls split using ',' as a delimiter, and invokes .map on the collection, # calling to_i (converts to integers) on each element