Coding conventions: Use 'z' as suffix for identifiers that could be singular or parallel
Something simple to do in your code that might otherwise require explanation or comments.
If a method accepts an argument which could either be a single element or array, use 'z' as a suffix, rather than the singular or plural name. This calls immediate attention that something is different, and once learned, is pretty clear on sight.
def add_itemz(itemz)
Array(itemz).each do |item|
# ...
end
end
Written by Doug Puchalski
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#