0

In PHP you can optionally make parameters pass by reference with an & in the function definition:

someFunction($byValue, &$byReference) { // $byValue is passed in by value // $byReference is passed in by reference due to the preceding & } 

Is this possible in Kotlin? If not, does anyone know if it's planned?

4
  • 1
    See stackoverflow.com/a/54689951/1246282 Commented Jan 3, 2020 at 19:13
  • 2
    Does this answer your question? Is Kotlin "pass-by-value" or "pass-by-reference"? Commented Jan 3, 2020 at 19:15
  • @Quinn yes the answer to my question can be derived from the question you linked though I don't see it as a direct duplicate as stated in the comment on your own answer. Commented Jan 3, 2020 at 21:25
  • 1
    @wheelmaker Yes you're right, it is not a direct duplicate, just a similar question. Sorry for my phrasing Commented Jan 3, 2020 at 21:28

1 Answer 1

1

I believe that similar to Java, Kotlin is always pass-by-value and optional pass-by-reference is not possible.

Sign up to request clarification or add additional context in comments.

2 Comments

Do you believe that or do you have any sources or even some code providing an example about this?
@NicoHaase see the duplicate question i linked in the comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.