Skip to content

Conversation

@phanan
Copy link
Collaborator

@phanan phanan commented Oct 5, 2019

This PR adds a noop() function which might be useful in certain cases.

/**
* A no-operation function.
*/
function noop()
Copy link
Owner

Choose a reason for hiding this comment

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

Would the return type be void or null?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Shouldn't it be void as it does nothing?

Copy link
Owner

Choose a reason for hiding this comment

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

Strictly speaking it would then be illegal to use it in a map

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There will always be an illegal case for any return type, right? 🤔

@lstrojny
Copy link
Owner

lstrojny commented Dec 9, 2019

One thing I am wondering: should this be a higher order function so that it returns a function?

@phanan
Copy link
Collaborator Author

phanan commented Dec 9, 2019

What would be the benefit of returning a function over a simple void?

@lstrojny
Copy link
Owner

Something like map($v, noop()) but it wouldn’t be in line with id()

@lstrojny lstrojny merged commit 0f7d89c into lstrojny:master Dec 13, 2019
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.

2 participants