Re: Type casting syntax
| From: | Max Semenik | Date: | Mon, 12 Jul 2021 17:56:50 +0000 |
| Subject: | Re: Type casting syntax | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-115413@lists.php.net to get a copy of this message | ||
On Mon, Jul 12, 2021 at 8:01 PM Mike Schinkel <mike@newclarity.net> wrote:
> Additionally in Go a type assertion can return a second value which is
> boolean telling if the type assertion succeeded. Not having this would
> effectively moot the benefit to a type assertion if you had to wrap with
> try{}catch{} in case it failed.
>
Not necessarily:
if ($obj instanceof MyClass) {
// We know its type here
} else {
// Try something else
}
--
Best regards,
Max Semenik