Call another method inside of method closure

Is it possible to add another method inside of a closure, and if so, how to properly do it? For instance,
->hint(function($get){
if ($get('stock') == 0){
('testing') // this is the hint text I want tot return if true;
}
->hint(function($get){
if ($get('stock') == 0){
('testing') // this is the hint text I want tot return if true;
}
As example, I'm grabbing the value of 'stock' field, and run a conditional statement. And if conditions are met, I want to show the hint text, and maybe add another method to that field, like hintIcon() of hintColor()
5 Replies
Dennis Koch
Dennis Koch2y ago
You can execute other methods. But if you want to add hint color you should do that in a separate closure.
Resonance
ResonanceOP2y ago
So how can I return the string value of the hint if conditions are met?
Dennis Koch
Dennis Koch2y ago
As you said: return a string
Resonance
ResonanceOP2y ago
return ('testing') is enough?
Dennis Koch
Dennis Koch2y ago
Yes.
Want results from more Discord servers?
Add your server