HISE Logo Forum
    • Categories
    • Register
    • Login

    Can we get the Logical And(&&) operator

    Scheduled Pinned Locked Moved Feature Requests
    8 Posts 5 Posters 268 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • oskarshO
      oskarsh
      last edited by

      Hey,

      can we get the && operator similar to the ? (ternary) operator?

      Basically && is a logical AND so:

      if (data.hover)
      {
          Console.print('really not so smoooth');
      }
      

      can become just one beautiful single line of code:

      data.hover && Console.print('smooooooth');
      

      I believe you can already achieve something like this by using:

      data.hover ? Console.print('not so smoooth') : null;
      

      however it lacks class and elegance :)) Its also a javascript basic for years now.

      d.healeyD ulrikU 2 Replies Last reply Reply Quote 0
      • d.healeyD
        d.healey @oskarsh
        last edited by d.healey

        @oskarsh already there just put it in parentheses. doesn't do what you want though, you still need a conditional statement

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        1 Reply Last reply Reply Quote 0
        • ulrikU
          ulrik @oskarsh
          last edited by

          @oskarsh

          and.gif

          Hise Develop branch
          MacOs 15.3.1, Xcode 16.2
          http://musikboden.se

          d.healeyD oskarshO ustkU 3 Replies Last reply Reply Quote 1
          • d.healeyD
            d.healey @ulrik
            last edited by

            @ulrik Woah, that's not what I expected

            Libre Wave - Freedom respecting instruments and effects
            My Patreon - HISE tutorials
            YouTube Channel - Public HISE tutorials

            1 Reply Last reply Reply Quote 0
            • oskarshO
              oskarsh @ulrik
              last edited by

              @ulrik wait what? Is this new??

              1 Reply Last reply Reply Quote 0
              • ustkU
                ustk @ulrik
                last edited by

                @ulrik Is this not dangerous? I mean console operations are removed/ignored at compile time so this might end up in a bug unless @Christoph-Hart has put a security... But I don't know...

                Can't help pressing F5 in the forum...

                ulrikU 1 Reply Last reply Reply Quote 0
                • ulrikU
                  ulrik @ustk
                  last edited by

                  @ustk actually I don't know either, I just tested this yesterday but I will not use it in my code unless I'm sure it's safe.
                  But it could be tested of course.

                  Hise Develop branch
                  MacOs 15.3.1, Xcode 16.2
                  http://musikboden.se

                  Christoph HartC 1 Reply Last reply Reply Quote 0
                  • Christoph HartC
                    Christoph Hart @ulrik
                    last edited by

                    The console operations are not removed but replaced with a noop, so the short-circuit logic still works the same.

                    1 Reply Last reply Reply Quote 3
                    • First post
                      Last post

                    27

                    Online

                    1.8k

                    Users

                    12.0k

                    Topics

                    104.8k

                    Posts