Click here to Skip to main content
15,888,610 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: I think my WTF per minute counter just overflowed... Pin
kmoorevs4-Sep-19 12:06
kmoorevs4-Sep-19 12:06 
GeneralRe: I think my WTF per minute counter just overflowed... Pin
Bernhard Hiller5-Sep-19 22:41
Bernhard Hiller5-Sep-19 22:41 
JokeRe: I think my WTF per minute counter just overflowed... PinPopular
Fueled By Decaff9-Sep-19 3:22
Fueled By Decaff9-Sep-19 3:22 
GeneralRe: I think my WTF per minute counter just overflowed... Pin
Private Dobbs30-Oct-19 22:32
Private Dobbs30-Oct-19 22:32 
GeneralRe: I think my WTF per minute counter just overflowed... Pin
#realJSOP9-Sep-19 5:21
mve#realJSOP9-Sep-19 5:21 
GeneralRe: I think my WTF per minute counter just overflowed... Pin
Keith Barrow15-Oct-19 11:47
professionalKeith Barrow15-Oct-19 11:47 
GeneralRe: I think my WTF per minute counter just overflowed... Pin
Bajaja30-Oct-19 22:13
professionalBajaja30-Oct-19 22:13 
GeneralKotlin: new(ish) syntax emerges Pin
raddevus15-Aug-19 10:36
mvaraddevus15-Aug-19 10:36 
In Kotlin you can do this:
Kotlin
var items = (1..300) // becomes an IntRange (range of integers)

Additionally you can call the shuffle() method on the range to randomly shuffle the ints.
Then you can call last() on the returned shuffled ints to get the random last item.
So if you want a list of 10 random values in the range of 1 - 1000, you can do it with just a couple of lines of Kotlin. Each time through the loop the range is shuffled and a new last() is chosen.
Kotlin
for (i in 1..10) {
   print((1..1000).shuffled().last())
   print (" | ")
}

Output looks like the following:
795 | 948 | 719 | 304 | 733 | 849 | 723 | 66 | 316 | 619 |

Try it out in your browser at : Try Kotlin[^]
These new types of syntax are ugly to me, but I can see that they could grow on a dev.

*Note:By emerges, I just mean that newer languages have syntax which looks similar to this. Kotlin has had the Range type for a long time.
Basically a fluent interface[^] but just interesting that it becomes more of a core part of syntax in newish languages.

modified 15-Aug-19 16:49pm.

GeneralRe: Kotlin: new(ish) syntax emerges Pin
Marc Clifton15-Aug-19 11:19
mvaMarc Clifton15-Aug-19 11:19 
GeneralRe: Kotlin: new(ish) syntax emerges Pin
raddevus15-Aug-19 12:29
mvaraddevus15-Aug-19 12:29 
GeneralRe: Kotlin: new(ish) syntax emerges Pin
Ryan Peden15-Aug-19 11:32
professionalRyan Peden15-Aug-19 11:32 
GeneralRe: Kotlin: new(ish) syntax emerges Pin
raddevus15-Aug-19 12:31
mvaraddevus15-Aug-19 12:31 
GeneralRe: Kotlin: new(ish) syntax emerges Pin
kalberts15-Aug-19 20:43
kalberts15-Aug-19 20:43 
GeneralRe: Kotlin: new(ish) syntax emerges Pin
Stuart Dootson15-Aug-19 21:28
professionalStuart Dootson15-Aug-19 21:28 
GeneralRe: Kotlin: new(ish) syntax emerges Pin
raddevus16-Aug-19 1:36
mvaraddevus16-Aug-19 1:36 
GeneralRe: Kotlin: new(ish) syntax emerges Pin
grumpy_nl15-Aug-19 22:41
grumpy_nl15-Aug-19 22:41 
GeneralRe: Kotlin: new(ish) syntax emerges Pin
raddevus16-Aug-19 1:37
mvaraddevus16-Aug-19 1:37 
GeneralRe: Kotlin: new(ish) syntax emerges Pin
Richard Deeming16-Aug-19 1:36
mveRichard Deeming16-Aug-19 1:36 
GeneralRe: Kotlin: new(ish) syntax emerges Pin
raddevus16-Aug-19 1:39
mvaraddevus16-Aug-19 1:39 
GeneralRe: Kotlin: new(ish) syntax emerges Pin
englebart16-Aug-19 2:09
professionalenglebart16-Aug-19 2:09 
GeneralRe: Kotlin: new(ish) syntax emerges Pin
Rob Grainger25-Sep-19 2:32
Rob Grainger25-Sep-19 2:32 
GeneralRe: Kotlin: new(ish) syntax emerges Pin
obermd16-Aug-19 4:14
obermd16-Aug-19 4:14 
GeneralRe: Kotlin: new(ish) syntax emerges Pin
Keith Barrow9-Sep-19 3:04
professionalKeith Barrow9-Sep-19 3:04 
GeneralMemory Leak PinPopular
Bernhard Hiller21-Jul-19 23:17
Bernhard Hiller21-Jul-19 23:17 
GeneralRe: Memory Leak Pin
Member 916705723-Jul-19 21:43
Member 916705723-Jul-19 21:43 

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.