• @RacerX@lemm.ee
    link
    fedilink
    223 months ago

    I was taught it in school, have looked it up on Wikipedia, seen infographics, YouTube videos, etc., and yet I still do not know when to use those things. At this point I just refuse to purely out of fear.

    • @stupidcasey@lemmy.world
      link
      fedilink
      173 months ago

      You generally use them at the end of a line but it is more accurate to say you use them at the end of a statement but we usually put each statement on a single line so it is easy to make that mistake example:

      Tap for spoiler
      <?php
      $x = 5; // Semicolon ends the statement
      $y = 10; // Another statement ends here
      
      if ($x < $y) { // No semicolon needed here
          echo "x is less than y"; // Semicolon ends this statement
      }
      
      $x = $x + $y; // Statement ends here
      echo $x; // Outputs 15
      ?>
      
    • @Serinus@lemmy.world
      link
      fedilink
      73 months ago

      I use them after worrying about being pretentious, but then (sometimes) deciding “fuck it. It’s right.” and then doing it anyway.

    • @prettybunnys@sh.itjust.works
      link
      fedilink
      6
      edit-2
      3 months ago

      You can use a semicolon wherever you’d logically break in a sentence, without pausing overtly, but intend to follow the thought; semi-colons slip naturally into your thought process when you practice it by speaking.

    • I have one easy rule, and two examples. Use them when using a comma would be confusing.

      Examples: often in lists, where each item might contain a comma and so trying to separate list items with commas would just be confusing; and more broadly anywhere where you have a sentance containing clauses and need a different separator.

      I just used the first example above: to separate the two list items, and the other one I’m using here, where I’m already using commas; using a semicolon allows braking this up without starting a new sentance.

      That second example was somewhat contrived, but does the job; it could have been two sentences.

      Actually, there’s another place I use them, but it’s not a “rule” and if more style: I use them selectively in place of periods to prevent a series of short, choppy sentences.

    • Meursault
      link
      fedilink
      23 months ago

      You would use a semi-colon in places where a comma and a colon would be equally suitable, pretty much.

      • @homicidalrobot@lemm.ee
        link
        fedilink
        33 months ago

        Where a period or a comma followed by “And” would go. Semicolon is a full break, distinctly more than a comma