def emails
i = 0
number = rand(252...4350)
males = ["tom", "jack", "adam"]
females = ["elizabeth", "rose", "juliet"]
surnameMales = ["oak", "yew", "timber"]
surnameFemales = ["rosewelth", "gates", "jobs"]
providers = ["gmail.com", "hotmail.com", "yahoo.com"]
while i <= 100 do
@addresses <<
end
end
我想做的是选择一个随机数,名字,姓氏和提供者,并把它们放在一起+在姓氏的末尾附加一个随机数,这样看起来,例如:
[email protected]
,但有点卡住了,我必须把整个东西放在一起。如您所知,我想创建一个100
随机电子邮件用于测试目的。你能告诉我怎样才能做我想做的事吗?
最佳答案
使用字符串插值和Array#sample的组合。
"#{females.sample}.#{surnameFemales.sample}#{rand(252...4350)}@#{providers.sample}"
>> "[email protected]"