Reputation: 111000
parse_emails('long list')
def parse_emails(emails)
.... stuff
return valid_emails, invalid_emails
end
I see that there are two arrays but how do I get them? I tried:
mylist = parse_emails('long list')
mylist[valid_emails]
but that error'd. ideas? thxs
Upvotes: 1
Views: 772
Reputation: 2961
You could pass the two arrays into the method, then populate them in there:
invalid_emails = []
valid_emails = []
parse_emails('long list', valid_emails, invalid_emails)
def parse_emails(emails, valid, invalid)
.... stuff
while ...
if is_valid?
valid << current_email
else
invalid << current_email
end
end
end
Upvotes: 0
Reputation: 40894
valid_emails, invalid_emails = parse_emails(whatever)
Please take time to read some basic intro into Ruby syntax ;)
Upvotes: 7
Reputation: 21971
Construct an class with two lists in it, one for valid emails and one for invalid emails and populate the object of this class in parse_emails function and return it.
Then, in the outside, you can access those two lists as properties of the return value.
Upvotes: 1