HiddenLayer555@lemmy.ml to Programmer Humor@programming.devEnglish · edit-213 days agoWhy make it complicated?lemmy.mlimagemessage-square107fedilinkarrow-up11arrow-down10file-textcross-posted to: [email protected]
arrow-up11arrow-down1imageWhy make it complicated?lemmy.mlHiddenLayer555@lemmy.ml to Programmer Humor@programming.devEnglish · edit-213 days agomessage-square107fedilinkfile-textcross-posted to: [email protected]
minus-squaresbv@sh.itjust.workslinkfedilinkEnglisharrow-up0·12 days agoRust and TypeScript use the return-type-at-the-end convention as well.
minus-squaredan@upvote.aulinkfedilinkarrow-up0·edit-212 days 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-up0·12 days 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.
Rust and TypeScript use the return-type-at-the-end convention as well.
Python too.
And Kotlin.
AND MY AXE!
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.