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

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -