Re: Type casting syntax

From: Date: Mon, 12 Jul 2021 20:20:32 +0000
Subject: Re: Type casting syntax
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-115415@lists.php.net to get a copy of this message
> On Jul 12, 2021, at 1:56 PM, Max Semenik <maxsem.wiki@gmail.com> wrote: > > On Mon, Jul 12, 2021 at 8:01 PM Mike Schinkel <mike@newclarity.net > <mailto: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 > } Well there you go. It seems you have just illustrated why in reality we really do not need type casting/assertions in PHP given its current features, because we already have what we need. -Mike

« previous php.internals (#115415) next »