HiddenLayer555@lemmy.ml to Programmer Humor@programming.devEnglish · edit-23 months agoWhy make it complicated?lemmy.mlimagemessage-square22linkfedilinkarrow-up1152arrow-down111file-textcross-posted to: programmerhumor@lemmy.ml
arrow-up1141arrow-down1imageWhy make it complicated?lemmy.mlHiddenLayer555@lemmy.ml to Programmer Humor@programming.devEnglish · edit-23 months agomessage-square22linkfedilinkfile-textcross-posted to: programmerhumor@lemmy.ml
minus-squaredan@upvote.aulinkfedilinkarrow-up1·edit-23 months agoTypeScript doesn’t need the “function” keyword for a method in an object or on a class though. const foo = { bar(): string { ... } } which I assume is doable because the syntax is unambiguous. PHP’s object orientation is similar to languages like Java and C#, which is what I was comparing to.
minus-squaresbv@sh.itjust.workslinkfedilinkEnglisharrow-up1arrow-down1·3 months agoYour example didn’t mention the use of the function keyword. Instead, it seemed to be questioning the placement of the return type - placing it after the argument list seems pretty common in newer languages.
TypeScript doesn’t need the “function” keyword for a method in an object or on a class though.
const foo = { bar(): string { ... } }
which I assume is doable because the syntax is unambiguous.
PHP’s object orientation is similar to languages like Java and C#, which is what I was comparing to.
Your example didn’t mention the use of the function keyword. Instead, it seemed to be questioning the placement of the return type - placing it after the argument list seems pretty common in newer languages.