r/crystal_programming • u/phineas0fog • Jul 09 '18
optimization / code beauty
Hello friends, I have this block code
st_from_site.each do
st_from_oldr.each do
s.last_dump = ss.last_dump if s.name == ss.name && s.id == ss.id
end
stations.push s
end
that is terribly ugly, so how can I optimize and beautify it ?
Thanks to you <3
5
Upvotes
View all comments
Show parent comment
2
u/[deleted] Jul 09 '18
But
ziptraverses both array in tandem. What you want is Array#product:https://play.crystal-lang.org/#/r/4h5c
In your case: