This file contains 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 GPSCoordinate | |
attr_reader :latitude, :longitude | |
def initialize(latitude, longitude) | |
@latitude = latitude | |
@longitude = longitude | |
end | |
end |
This file contains 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
def flatten(input) | |
raise ArgumentError.new("Only arrays are allowed") if !input.is_a?(Array) | |
output = [] | |
input.each do |element| | |
if element.is_a?(Array) | |
output += flatten(element) | |
else | |
output << element | |
end | |
end |