Click here to Skip to main content
14,244,034 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Typos in product code Pin
Jacquers18-Jun-19 23:38
memberJacquers18-Jun-19 23:38 
GeneralRe: Typos in product code Pin
Gary Wheeler19-Jun-19 1:35
memberGary Wheeler19-Jun-19 1:35 
GeneralRe: Typos in product code Pin
englebart19-Jun-19 2:04
memberenglebart19-Jun-19 2:04 
GeneralRe: Typos in product code Pin
Gerry Schmitz19-Jun-19 8:15
mveGerry Schmitz19-Jun-19 8:15 
GeneralRe: Typos in product code Pin
#realJSOP20-Jun-19 23:41
mve#realJSOP20-Jun-19 23:41 
GeneralRe: Typos in product code Pin
CodeWraith24-Jun-19 3:01
memberCodeWraith24-Jun-19 3:01 
GeneralRe: Typos in product code Pin
Super Lloyd26-Jun-19 17:57
memberSuper Lloyd26-Jun-19 17:57 
Generallet, var, val - Swift, Kotlin, JavaScript Pin
raddevus12-Jun-19 11:02
mvaraddevus12-Jun-19 11:02 
If you do native iOS (Swift) and native Android (Kotlin now) and web dev (JavaScript), you will find that Swift, Kotlin and JavaScript will have you going crazy in their choice of usage of : let, var, and val

They use similar keywords all in different ways.

Swift
let pi = 3.14 // defines constant
var randValue = 55; // defines variable

Of course, let does something different in JavaScript. Of course... Sigh | :sigh:
JavaScript
let x = 1; // outer scope
var y = 7; // (global scope)

if (x === 1) {
  let x = 2;  // DIFFERENT x (local scope)
  var y = 107; // SAME Y (global scope)

  console.log(x); // expected output: 2
  console.log(y); // expected output : 107
}
console.log(x) // expected output: 1
console.log(y); // expected output: 107


Kotlin Note: CP doesn't have a choice for Kotlin yet, so val keyword isn't blue.
val pi = 3.14 // defines constant
var randValue = 55; // defines variable


var is used by all three.
let is used by Swift and JavaScript differently.
val is only used by Kotlin.

Language Design Ideas
We know everyone steals design ideas from each other, so why didn't the designers of these languages steal from each other and make let and var mean the same darn things?!? Dead | X|
GeneralRe: let, var, val - Swift, Kotlin, JavaScript Pin
Eddy Vluggen12-Jun-19 11:37
mveEddy Vluggen12-Jun-19 11:37 
GeneralRe: let, var, val - Swift, Kotlin, JavaScript Pin
raddevus12-Jun-19 12:05
mvaraddevus12-Jun-19 12:05 
GeneralRe: let, var, val - Swift, Kotlin, JavaScript Pin
Eddy Vluggen12-Jun-19 12:15
mveEddy Vluggen12-Jun-19 12:15 
GeneralRe: let, var, val - Swift, Kotlin, JavaScript Pin
den2k8812-Jun-19 22:30
professionalden2k8812-Jun-19 22:30 
GeneralRe: let, var, val - Swift, Kotlin, JavaScript Pin
raddevus13-Jun-19 1:51
mvaraddevus13-Jun-19 1:51 
GeneralRe: let, var, val - Swift, Kotlin, JavaScript Pin
Member 916705712-Jun-19 20:37
memberMember 916705712-Jun-19 20:37 
GeneralRe: let, var, val - Swift, Kotlin, JavaScript Pin
Richard Deeming12-Jun-19 23:25
mveRichard Deeming12-Jun-19 23:25 
GeneralRe: let, var, val - Swift, Kotlin, JavaScript Pin
obermd13-Jun-19 4:10
memberobermd13-Jun-19 4:10 
GeneralRe: let, var, val - Swift, Kotlin, JavaScript Pin
raddevus13-Jun-19 1:42
mvaraddevus13-Jun-19 1:42 
GeneralRe: let, var, val - Swift, Kotlin, JavaScript Pin
Member 798912213-Jun-19 6:44
memberMember 798912213-Jun-19 6:44 
GeneralRe: let, var, val - Swift, Kotlin, JavaScript Pin
Member 916705717-Jun-19 20:42
memberMember 916705717-Jun-19 20:42 
GeneralRe: let, var, val - Swift, Kotlin, JavaScript Pin
Member 798912217-Jun-19 23:09
memberMember 798912217-Jun-19 23:09 
GeneralRe: let, var, val - Swift, Kotlin, JavaScript Pin
Member 916705718-Jun-19 0:10
memberMember 916705718-Jun-19 0:10 
GeneralRe: let, var, val - Swift, Kotlin, JavaScript Pin
Sander Rossel12-Jun-19 22:05
professionalSander Rossel12-Jun-19 22:05 
GeneralRe: let, var, val - Swift, Kotlin, JavaScript Pin
raddevus13-Jun-19 1:44
mvaraddevus13-Jun-19 1:44 
GeneralRe: let, var, val - Swift, Kotlin, JavaScript Pin
den2k8812-Jun-19 22:28
professionalden2k8812-Jun-19 22:28 
GeneralRe: let, var, val - Swift, Kotlin, JavaScript Pin
Richard Deeming12-Jun-19 23:34
mveRichard Deeming12-Jun-19 23:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.