Why make it complicated?
-
wrote on last edited by [email protected]
Made with KolourPaint and screenshots from Kate (with the GitHub theme).
-
Made with KolourPaint and screenshots from Kate (with the GitHub theme).
You're encoding more information in the typescript one. You're saying it's a string that will get updated.
-
You're encoding more information in the typescript one. You're saying it's a string that will get updated.
That looks like rust ngl
-
Made with KolourPaint and screenshots from Kate (with the GitHub theme).
I've always wondered where all this 'let' business started
-
I've always wondered where all this 'let' business started
wrote on last edited by [email protected]It's commonly used in math to declare variables so I assume programming languages borrowed it from there.
-
You're encoding more information in the typescript one. You're saying it's a string that will get updated.
Yeah, it's explicitly distinct from
const a: String
which says it won't change, andvar a: String
, which means this is legacy code that needs fixing. -
You're encoding more information in the typescript one. You're saying it's a string that will get updated.
You aren't though. In most languages that use the latter declaration you would prefix the declaration with final or const or the like to specify it won't be updated.
-
It's commonly used in math to declare variables so I assume programming languages borrowed it from there.
BASIC uses (used?) it to declare variables. (I don't know if earlier languages did.)
Not that that's a reason for other languages to copy it.
-
BASIC uses (used?) it to declare variables. (I don't know if earlier languages did.)
Not that that's a reason for other languages to copy it.
wrote on last edited by [email protected]Doesn't Basic use
Dim a As String
? -
Made with KolourPaint and screenshots from Kate (with the GitHub theme).
python:
a: str = 1
-
I've always wondered where all this 'let' business started
More than you'd ever want to know: https://en.m.wikipedia.org/wiki/Let_expression
-
Yeah, it's explicitly distinct from
const a: String
which says it won't change, andvar a: String
, which means this is legacy code that needs fixing.If there's only two options you only need one keyword
-
Doesn't Basic use
Dim a As String
?wrote on last edited by [email protected]Older variants used DIM for arrays and LET for other variables. DIM was originally called that because it was setting the dimensions of the array.
In modern BASIC variants, DIM has become a backronym: "declare in memory".
-
Made with KolourPaint and screenshots from Kate (with the GitHub theme).
Can we talk about PHP functions with typehints too?
public static function foo(): string {
Practically every other language with similar syntax does this instead:
public static string foo() {
-
Can we talk about PHP functions with typehints too?
public static function foo(): string {
Practically every other language with similar syntax does this instead:
public static string foo() {
TIL PHP has statics.
Also, does PHP actually enforce the type declarations? I'd assume it would but knowing PHP...
-
TIL PHP has statics.
Also, does PHP actually enforce the type declarations? I'd assume it would but knowing PHP...
It enforces scalar types (string, int, etc) at runtime if you enable strict mode. There's also static analysis tools like PHPStan and Psalm that will flag issues at build time.
-
Older variants used DIM for arrays and LET for other variables. DIM was originally called that because it was setting the dimensions of the array.
In modern BASIC variants, DIM has become a backronym: "declare in memory".
TIL Backronyms and cuil BASIC technicalities
Much obliged all -
python:
a: str = 1
And then assign an int to a string just to mess with the interpreter.
-
Made with KolourPaint and screenshots from Kate (with the GitHub theme).
First time i used let it was to inline variable declaration with assignment . Can’t remember the language.
-
Older variants used DIM for arrays and LET for other variables. DIM was originally called that because it was setting the dimensions of the array.
In modern BASIC variants, DIM has become a backronym: "declare in memory".
Even older variants required both a let to declare the variable and a dim to set its size.
I remember a
REDIM
command, but I really can't remember what basic it's from.