Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Roy Leung
1,272 PointsHow do I know which method would change the call object itself if there is no "!" required. It seems confused
like the function keep_if will change the call object itself but without symbol "!". It seems not consistency.
2 Answers

Dylan Shine
17,565 PointsIn the Ruby Code Docs (http://www.ruby-doc.org/core-2.1.3/Array.html#method-i-keep_if) there are methods that are destructive and non destructive. Since .keep_if is a destructive method, it will modify the array regardless of having a ! sign. To check if a method is destructive or now, look at whether the method you're using also has a ! version listed in the Ruby Core Docs.

Dylan Shine
17,565 PointsCorrect, in order to not modify your array chances are you're going to need to duplicate it before you operate on it.
Roy Leung
1,272 PointsRoy Leung
1,272 Pointsso that means, there is no ! sign version for destructive methods.