230
if statement == false (i.imgflip.com)
you are viewing a single comment's thread
view the rest of the comments
[-] ptz@dubvee.org 40 points 1 week ago* (last edited 1 week ago)

Hey, I like a little chaos in my codebase ๐Ÿ˜†

const funsies = () => (Math.round(Math.random() * 1000) % 2 == 0)
if ( condition || funsies() ) {
    // do the thing
}
[-] sorrybookbroke@sh.itjust.works 6 points 1 week ago* (last edited 1 week ago)

Wait, why the the *1000 or mod 2? Won't that give a 50\50 chance or the same as Math.round(Math.random).

No shade, and I may be wrong myself I am very tired

[-] mexicancartel@lemmy.dbzer0.com 2 points 1 week ago

Probably to make the fractional random value between 0 and 1 to become an integer so that you can divisibility check for even with mod 2

[-] modality@lemmy.myserv.one 3 points 1 week ago
[-] ptz@dubvee.org 19 points 1 week ago* (last edited 1 week ago)

Nope. I'm staunchly against "AI". If the code sucks, it's because I wrote bad code.

Edit: Oh, or did you mean is that how "AI" works?

this post was submitted on 05 Dec 2024
230 points (93.2% liked)

Science Memes

11399 readers
1287 users here now

Welcome to c/science_memes @ Mander.xyz!

A place for majestic STEMLORD peacocking, as well as memes about the realities of working in a lab.



Rules

  1. Don't throw mud. Behave like an intellectual and remember the human.
  2. Keep it rooted (on topic).
  3. No spam.
  4. Infographics welcome, get schooled.

This is a science community. We use the Dawkins definition of meme.



Research Committee

Other Mander Communities

Science and Research

Biology and Life Sciences

Physical Sciences

Humanities and Social Sciences

Practical and Applied Sciences

Memes

Miscellaneous

founded 2 years ago
MODERATORS