Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. It does what now?

It does what now?

Scheduled Pinned Locked Moved The Weird and The Wonderful
question
8 Posts 8 Posters 0 Views 1 Watching
  • 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.
  • U Offline
    U Offline
    User 8661269
    wrote on last edited by
    #1

    private void toggleSwitch(bool? visible = false)
    {
    if (visible.Value) toggleState(visible);
    }

    B P K M O 6 Replies Last reply
    0
    • U User 8661269

      private void toggleSwitch(bool? visible = false)
      {
      if (visible.Value) toggleState(visible);
      }

      B Offline
      B Offline
      Brisingr Aerowing
      wrote on last edited by
      #2

      :doh: Well, it is completely redundant, and why is it Nullable? I guess the developer had a case of hypocaffenia and encountered a '404: Brain Not Found' error.

      Bob Dole

      The internet is a great way to get on the net.

      :doh: 2.0.82.7292 SP6a

      B 1 Reply Last reply
      0
      • B Brisingr Aerowing

        :doh: Well, it is completely redundant, and why is it Nullable? I guess the developer had a case of hypocaffenia and encountered a '404: Brain Not Found' error.

        Bob Dole

        The internet is a great way to get on the net.

        :doh: 2.0.82.7292 SP6a

        B Offline
        B Offline
        Brady Kelly
        wrote on last edited by
        #3

        Zac Greve wrote:

        hypocaffenia

        Love it! :cool:

        1 Reply Last reply
        0
        • U User 8661269

          private void toggleSwitch(bool? visible = false)
          {
          if (visible.Value) toggleState(visible);
          }

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          It's entirely possible that they would pass null into toggleSwitch. Of course, it should be HasValue rather than Value.

          *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

          "Mind bleach! Send me mind bleach!" - Nagy Vilmos

          CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

          1 Reply Last reply
          0
          • U User 8661269

            private void toggleSwitch(bool? visible = false)
            {
            if (visible.Value) toggleState(visible);
            }

            K Offline
            K Offline
            kdmote
            wrote on last edited by
            #5

            It's not redundant at all. But it probably doesn't function the way the author intended. What the author probably had in mind was:

            private void toggleSwitch(bool? visible = false)
            {
            toggleState(visible);
            }

            ...which wraps a non-nullable toggle function with a nullable one. But as it is written, the functionality that this method offers is actually: 1. If user passes toggleSwitch(True), then toggleState is toggled. BUT, 2. If user passes toggleSwitch(False) or toggleSwitch(), then NOTHING happens (because of the test).

            1 Reply Last reply
            0
            • U User 8661269

              private void toggleSwitch(bool? visible = false)
              {
              if (visible.Value) toggleState(visible);
              }

              M Offline
              M Offline
              Marius Bancila
              wrote on last edited by
              #6

              Congrats. You have successfully installed bugs! :)

              1 Reply Last reply
              0
              • U User 8661269

                private void toggleSwitch(bool? visible = false)
                {
                if (visible.Value) toggleState(visible);
                }

                O Offline
                O Offline
                onelopez
                wrote on last edited by
                #7

                Granted you don't pass a null value, the component / control will always remain in

                .Visible = false

                But if false is passed, there's nothing there that will turn the control /component back on again.

                1 Reply Last reply
                0
                • U User 8661269

                  private void toggleSwitch(bool? visible = false)
                  {
                  if (visible.Value) toggleState(visible);
                  }

                  V Offline
                  V Offline
                  Vladimir Svyatski
                  wrote on last edited by
                  #8

                  It throws an exception when visible == null.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups