我不确定这个问题是否过于愚蠢,但我还没有找到办法.
通常将数组放入循环中我这样做
current_humans = [.....]
current_humans.each do |characteristic|
puts characteristic
end
Run Code Online (Sandbox Code Playgroud)
但是,如果我有这个:
class Human
attr_accessor:name,:country,:sex
@@current_humans = []
def self.current_humans
@@current_humans
end
def self.print
#@@current_humans.each do |characteristic|
# puts characteristic
#end
return @@current_humans.to_s
end
def initialize(name='',country='',sex='')
@name = name
@country = country
@sex = sex
@@current_humans << self #everytime it is save or initialize it save all the data into an array
puts "A new human has been instantiated"
end
end
jhon = Human.new('Jhon','American','M')
mary = Human.new('Mary','German','F')
puts Human.print
Run Code Online (Sandbox Code Playgroud)
它不起作用. …
我想导出所有对我的消息停止回复(选择退出)的人。我看到我的选择是
肯定有一种简单的方法可以让我获得所有选择退出的号码列表吗?