ruby - How do I define this reject method from the Gosu library tutorial? -


i'm wondering how define reject in code the gosu tutorial:

def collect_stars(star)   if star.reject! {|star| gosu::distance(@x, @y, star.x, star.y) < 35}     @score += 1   end end 

looking @ tutorial, don't see reject defined. define it?

the code refers stars.reject! makes sense that's built-in array reject! method:

def collect_stars(stars)   if stars.reject! {|star| gosu::distance(@x, @y, star.x, star.y) < 35 }     @score += 1   end end 

what you've done here switched star.reject! different, it's acting against class star. i'm not sure intent there.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -