I'm new to Ruby and I'm just having a play around with ideas and what I would like to do is remove the @continent data from the country_array I have created. Done a good number of searches and can find quite a bit of info on removing elements in their entirety but can't find how to specifically remove @continent data. Please keep any answers fairly simple as I'm new, however any help much appreciated.
class World
include Enumerable
include Comparable
attr_accessor :continent
def <=> (sorted)
@length = other.continent
end
def initialize(country, continent)
@country = country
@continent = continent
end
end
a = World.new("Spain", "Europe")
b = World.new("India", "Asia")
c = World.new("Argentina", "South America")
d = World.new("Japan", "Asia")
country_array = [a, b, c, d]
puts country_array.inspect
[#<World:0x100169148 @continent="Europe", @country="Spain">,
#<World:0x1001690d0 @continent="Asia", @country="India">,
#<World:0x100169058 @continent="South America", @country="Argentina">,
#<World:0x100168fe0 @continent="Asia", @country="Japan">]
sortedin the definition of<=>?, and where forsothercome from?