[SOLVED] How to get function's parameter value without parameter name in swift?

Issue

func test(_: [Int]) {
  print("xxx")
}

test([1,2,3])

I saw this code is valid in swift, how can I get the value passed into test?

Solution

To explicitly answer your question:

how can I get the value passed in test?

You can’t, in the same way that after

let _ = someFunction() 

you have no way to get at the return value of someFunction. That’s really the whole point of _ which basically means "I’m ignoring this intentionally".

Answered By – Gereon

Answer Checked By – Terry (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published.