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! While you're at it, check out some resources Treehouse students have shared here.
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
Sebastian Velandia
24,676 PointsWhat is the exact function of the ? in the examples with all and any?
Hello in the example Jason explain with any and all I see this syntax
array1.all? {|item| item>3}
What is the function of the ? symbol in that sentence?
I mean, is the ? part of the name of the funcion all and any?
Because in the example with select Jason did not use the ? symbol
1 Answer
Geoff Parsons
11,679 PointsIn ruby you can use ! and ? as part of your method names. They're some idiomatic suggestions as to when to use them but they do not affect how the method functions in any way - they're just part of the name.
Typically you would see methods ending in a question mark when they return true or false for a state such as string#empty?.
And you'd end a method in an exclamation point when it modifies the object it is acting on for example string#gsub vs string#gsub!.
Maciej Czuchnowski
36,441 PointsMaciej Czuchnowski
36,441 PointsWhich video?