Masthash

#amProgramming

Zuri
1 week ago

It would be nice if we could spread/unpack arrays in match conditional expressions in #PHP

#webDevelopment #syntacticSugar #amProgramming #phpWishlist

<?php
  
$allowList = [ 1, 3, 5 ];
$denyList = [ 2, 4, 6 ];
$value = 2;

// instead of
match($value) {
  1, 3, 5 => print 'OK',
  2, 4, 6 => throw new ForbiddenHttpException,
};

// or
match($value) {
  $allowList[0], $allowList[1], $allowList[2] => print 'OK',
  $denyList[0], $denyList[1], $denyList[2] => throw new ForbiddenHttpException,
};

// or
match(true) {
  in_array($value, $allowList) => print 'OK',
  in_array($value, $denyList) => throw new ForbiddenHttpException,
};

// it would be nice if we could do
match($value) {
  ...$allowList => print 'OK',
  ...$denyList => throw new ForbiddenHttpException,
};

// and/or
match($value) {
  list($allowList) => print 'OK',
  list($denyList) => throw new ForbiddenHttpException,
};
aburka 🫣
1 month ago

When I'm getting out a calculator to say "now what is that number mod 2^16" you know a really bad bug is being investigated... #embedded #AmProgramming

Zuri
4 months ago

TIL To easily enter multi-line code into #tinker without trailing slashes at every line, you can enter the string "enter" into your terminal window and then press ENTER. This will open an editor (e.g. nano), where you can edit your code just like normal. When you are ready, you can simply save and exit. Thereafter, tinker executes the entered code ✨ πŸš€
🀯
#laravel #amProgramming #codingTips #webdevelopment

Zuri
4 months ago

#amProgramming #amCoding #introduction: Hi! πŸ‘‹πŸ»
I don't just juggle "real" languages a lot, I also utilize scripting and programming languages to make a living. I'm a #FullStack #developer for 14 years, 9 of them professionally (6 if you exclude the apprenticeship), using #laravel as backend and am always exited for progress in #ECMAScript as well as how to write better code. I also code in my spare time when I'm not writing or editing.
1/
#PHP

Well. The moral of that story is putting a line break in a file name does not lead to a useful outcome.
#amProgramming #fixingTypos

So apparently my algorithm worked fine. After I fixed typos in puncutation and spelling variable names... #amprogramming

J. Rosenbaum (they/them)
10 months ago

I am having a normal one working away… #cat #amProgramming and no he is not helping!

An extremely chonky white and black cat taking up the entirety of my lap while I work at my iMac. You can see my red slippers poking out at the end! My keyboard is balanced carefully on him. He doesn’t seem to mind. It was hard to take this picture.