Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove symbolic multiple param methods #10229

Closed
wants to merge 1 commit into from

Conversation

mkurz
Copy link
Member

@mkurz mkurz commented Apr 25, 2020

Fixes #10221

@NthPortal I guess this is what you were talking about?

override def +(e1: TypedEntry[_], e2: TypedEntry[_]): TypedMap =
new DefaultTypedMap(m + (e1.key -> e1.value) + (e2.key -> e2.value))
override def +(e1: TypedEntry[_], e2: TypedEntry[_], e3: TypedEntry[_]): TypedMap =
new DefaultTypedMap(m + (e1.key -> e1.value) + (e2.key -> e2.value) + (e3.key -> e3.value))
override def +(entries: TypedEntry[_]*): TypedMap = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you also shouldn't have this varargs method. instead, it should take a single arg such as an IterableOnce, and it is general practice to name it ++. the same for - with varargs (should take a collection and and be called --)

@octonato
Copy link
Contributor

@mkurz, I see that Flash and Session also use + and - for single param and ++ and -- for Iterable. It will be good to align the style in that case.

It's a common practice to overload the symbolic operators with named methods: add, remove, addAll, removeAll. However, Play is not following that convention anyway. Flash and Session do not have overloaded variants.

@mkurz
Copy link
Member Author

mkurz commented Feb 17, 2023

Done in #11672

@mkurz mkurz closed this Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple (non-implicit) parameters to a symbolic/infix should be avoided
3 participants