• PetDinosaurs@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    10 months ago

    Which language are we talking here? Cpp? Because typeof hasn’t ever seemed useful to me in how I use cpp or how I have ever really used a language. I also remember it being criticized in java class more than 20 years ago when OOP was solely preached, even for scientific people like me.

    • Konlanx@feddit.de
      link
      fedilink
      arrow-up
      0
      ·
      edit-2
      10 months ago

      This is likely referring to TypeScript.

      TypeScript has all of these patterns, they are used very frequently and they are necessary because TypeScript tends to be interesting from time to time since its types only exist at compile time, because it compiles to JavaScript, which is a language without types.

      TypeScript also allows any as a keyword, which says “I don’t know which type this is and I don’t care”, which still produces valid JavaScript. To get back to typed variables it is necessary to use typeof (or similar constructs like a type guard).

      https://www.typescriptlang.org/docs/handbook/2/typeof-types.html

  • UFO@programming.dev
    link
    fedilink
    arrow-up
    0
    ·
    edit-2
    10 months ago

    In Scala:

    case class Fix[F[_]](unfix: F[Fix[F]])
    case class Pie[T](filling: T)
    def ohNo: Fix[Pie] = Fix(Pie(ohNo))
    
  • Knusper@feddit.de
    link
    fedilink
    arrow-up
    0
    ·
    10 months ago

    In this thread: Trying to guess the programming language based on a single keyword and angle brackets. 🙃