I thought that by convention, only methods with an exclamation mark altered the object.
> array = [1, 2, 3]
=> [1, 2, 3]
> array.pop
=> 3
> array
=> [1, 2]
Why isn’t Array‘s pop method called pop!?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That’s not quite correct.
From The Ruby Style Guide
The names of potentially "dangerous" methods (i.e. methods that modify self or the arguments, exit! (doesn’t run the finalizers like exit does), etc.) should end with an exclamation mark if there exists a safe version of that dangerous method.
And the name of pop method says exactly what it is doing so there’s no need to sign it with exclamation mark.