Take this basic function:
func sampleFunction ()
{
print( self )
}
Here self
refers to the class instance that envelopes it, rather than - as might arguably make more sense - the function that envelopes it.
How does one get a reference to the enveloping function rather than its enveloping class instance?
Ideally, I'm looking to do something like this:
func sampleFunction ( value: Int )
{
print( selfAsEnvelopingSampleFunction, value )
}
If you want to print the name of the function, you can use __FUNCTION__
print(__FUNCTION__)
in your print statement, otherwise just use sampleFunction
as an argument .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With