I'm trying to print out the values of a hash where their corresponding keys match a certain condition (if they're odd).
I'm having an issue that's causing my loop to stop working after
The following code returns only the first matching value.
if mycondition
for key,value in myhash do
if key.odd?
return "#{value}"
end
end
end
After reading some other questions, I thought return was my issue, but when I take it out, the code returns the entire hash instead of just one matching value.
Anyone know what might be up?
Aucun commentaire:
Enregistrer un commentaire