Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

About infix function convention #47

Open
doljae opened this issue Dec 31, 2022 · 1 comment
Open

About infix function convention #47

doljae opened this issue Dec 31, 2022 · 1 comment

Comments

@doljae
Copy link

doljae commented Dec 31, 2022

Is there a style guide or convention for how to declare an infix function?
I wonder what is the officially recommended way, or what is the most used way.

1

infix fun Class.test(something: Something): Class = this.test(something)

2

infix fun Class.test(something: Something): Class = test(something)

3

infix fun Class.test(something: Something): Class { return this.test(something) }

4

infix fun Class.test(something: Something): Class { return test(something) }
@JakeWharton
Copy link

None of those options have anything specific to do with the use of infix but are general variations on ways to write the body of an extension function (or a non-extension member function).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants