Is it a sane idea to add to_an? as an alias to to_a?

55 views
Skip to first unread message

Artur Martsinkovskyi

unread,
Apr 19, 2018, 3:51:14 PM4/19/18
to Ruby on Rails: Core
As far as I am concerned, Rails try to be as clear and readable as possible in the means of DSL practices. They give the developer all tools for his code to be read like English. We even have aliases like "days" and "minutes" to "day" and "minute" to make forms like 5.days to be read more naturally. 
Writing something like "is_a? Integer" doesn't sound really euphonic to my ear and mind. "is_an? Integer" sounds much better. 

Is it OK to submit such a pull request as a part of ActiveSupport core extensions?

Rafael Mendonça França

unread,
Apr 19, 2018, 4:44:17 PM4/19/18
to Ruby on Rails: Core
Ruby used to have `exists?` and `exist?`. The former was deprecatted even that in some care it is more natual to read.

I’d follow the same rule here. I believe consistence is more important than readability in this case. It make code easier to search, since you only need to search for `is_a?` and not `is_an?` and it doesn’t introdoce the overhead of having to change which method you use when you rename the constant.

Rafael França
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-co...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages