On 10 September 2017 at 12:09, Tony Marston wrote:
>
> So why are you proposing a third alternative to the switch of if/elseif
> statements?
Because they think it's a good idea.
Not everyone is going to agree, which is why we have voting for RFCs.
cheers
Dan
Ack
--
PHP Internals - PHP Runtim
wrote in message news:3b05768a-95b7-42de-8bb8-3d9ce0cce3a5@Spark...
it makes it impossible to group several conditions with a single break
In Swift you can group multiple conditions with a comma `,` and in Rust
with a pipe `|`. Here’s how that could look in PHP:
```php
match ($x) {
1, 2
> it makes it impossible to group several conditions with a single break
In Swift you can group multiple conditions with a comma `,` and in Rust with a
pipe `|`. Here’s how that could look in PHP:
```php
match ($x) {
1, 2: ‘One or two’;
}
```
The only thing you cannot do is this:
```php
sw
wrote in message news:7cd2884a-6606-4c3f-8f95-776fd277878b@Spark...
Hi Tony
… you sometimes forget to insert a break statement then that is your
fault.
Any bug in your source code is ultimately your fault. But as mentioned
before human error is inevitable. You can make it easier for your us
Hi Tony
> … you sometimes forget to insert a break statement then that is your fault.
Any bug in your source code is ultimately your fault. But as mentioned before
human error is inevitable. You can make it easier for your users to make less
mistakes though. Other languages (e.g. Rust or Swift)
wrote in message news:eb28362c-4f8f-45df-bbf0-582e8ad2b8af@Spark...
Hi everybody!
Has this idea been discussed before?
I find myself writing switch statements in PHP quite rarely. This has a few
reasons:
1. It doesn’t have a "strict_types” version
2. It is quite verbose (lots of breaks)
3.
> Applying break statements is the first thing you should do if you intend
> to break. That way it can't be forgotten.
You should also immediately free the memory you’ve allocated but memory leaks
still happen all the time.
Human error is inevitable.
The more the compiler can do for you automati
On 9/9/2017 5:18 AM, Dan Ackroyd wrote:
for when you forget to put break.
Applying break statements is the first thing you should do if you intend
to break. That way it can't be forgotten.
--
Thomas Hruska
CubicleSoft President
I've got great, time saving software that you will find useful
On 9 September 2017 at 12:21, wrote:
> Hi everybody!
>
> Has this idea been discussed before?
> ..
> Each case has an implicit `break`
This part has come up before, as the default behaviour of fall through
is a nasty gotcha for when you forget to put break. I can't find the
conversation right no
Hi,
Something like:
function match($x) {
switch(true) {
case $x === 1:
return 'Tiny';
case is_numeric($x) && $x <= 10:
return 'Small';
case is_numeric($x) && $x <= 20:
return 'Medium';
case is_numeric($x) && $x <= 30:
10 matches
Mail list logo