Remix.run Logo
▲ IshKebab a day ago

If you access the bool through a long path maybe.

  foo.bar().baz[expensive()].qux.toggle();
▲crabmusket a day ago | parent | next [-]

This gives me the same feeling as when I saw Rust's map Entry API

https://doc.rust-lang.org/std/collections/hash_map/enum.Entr...

    let mut map: HashMap<&str, u32> = HashMap::new();
    map.entry("poneyland").or_insert(3);
    assert_eq!(map["poneyland"], 3);
It's very ergonomic.
▲jacksontheel a day ago | parent | prev | next [-]

Alright, I'm convinced, that makes a lot of sense.

▲Sharlin 21 hours ago | parent [-]

You can of course also do

  long_path_bool ^= true;
but that’s less obvious.
▲ammar_az a day ago | parent | prev | next [-]

That's the main reason for me as well

▲voxelghost 21 hours ago | parent | prev [-]

cant you just do

    foo.bar().baz[expensive()].qux ^= true;
▲IshKebab 20 hours ago | parent [-]

Sure, but should you?