T
Tj Superfly
Is it possible to send two different variables to one definition and
then use them separately in that definition?
Here's what I'm trying to do.
==============
#item = url
#species = pet
def exists(item)
existingitems = YAML.load(File.open("./#{species}.yaml"))
existingitems.each {
|exist|
if exist == item
return false
end
}
return true
end
pets.each do |pet|
files.each do |url|
if exists(url)
# here I want to send both the pet and url variable up to definition
puts "Exists"
else
puts "Nope"
end
end
end
=============
I have it all working with just the url, but I need it to know what pet
it's on so it knows what file to open and search in.
Anyone have any suggestions?
P.S. This code isn't an exact copy, I took out a lot of fluff and stuff
to shorten it for the example; it probably won't work if you try and
test the code. I'm just looking to see if there is a way to send both
variables up to the definition and then be able to use them?
then use them separately in that definition?
Here's what I'm trying to do.
==============
#item = url
#species = pet
def exists(item)
existingitems = YAML.load(File.open("./#{species}.yaml"))
existingitems.each {
|exist|
if exist == item
return false
end
}
return true
end
pets.each do |pet|
files.each do |url|
if exists(url)
# here I want to send both the pet and url variable up to definition
puts "Exists"
else
puts "Nope"
end
end
end
=============
I have it all working with just the url, but I need it to know what pet
it's on so it knows what file to open and search in.
Anyone have any suggestions?
P.S. This code isn't an exact copy, I took out a lot of fluff and stuff
to shorten it for the example; it probably won't work if you try and
test the code. I'm just looking to see if there is a way to send both
variables up to the definition and then be able to use them?