GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

Conversation

Notices

  1. Embed this notice
    Nick Lockwood (nicklockwood@mastodon.social)'s status on Thursday, 09-May-2024 01:12:29 JST Nick Lockwood Nick Lockwood

    In a fit of madness I've agreed to give an internal talk about advanced Swift at my company. Has anybody got any favorite Swift tricks they'd like to share?

    In conversation about a year ago from mastodon.social permalink
    • Embed this notice
      Paul Cantrell (inthehands@hachyderm.io)'s status on Thursday, 09-May-2024 01:12:28 JST Paul Cantrell Paul Cantrell
      in reply to

      @nicklockwood
      Don’t know if these qualify as “advanced” so much as “oft overlooked,” but:

      - reduce(into:) is useful

      - underscores can make large numbers readable: 1_000_000

      - ContinuousClock is useful

      - If you want an “open enum” (i.e. clients of lib can add cases), don’t use enum; use e.g. `protocol Color` + possibly empty `struct Mauve: Color` for cases, then match with `value is Mauve`, or `case let value as Mauve` if you need to narrow the type of `value` when matched

      In conversation about a year ago permalink
    • Embed this notice
      Nick Lockwood (nicklockwood@mastodon.social)'s status on Thursday, 09-May-2024 01:22:11 JST Nick Lockwood Nick Lockwood
      in reply to
      • Paul Cantrell

      @inthehands these are great, thank you!

      In conversation about a year ago permalink
    • Embed this notice
      Paul Cantrell (inthehands@hachyderm.io)'s status on Thursday, 09-May-2024 01:22:11 JST Paul Cantrell Paul Cantrell
      in reply to

      @nicklockwood You bet! Lmk if the open enum one is incomprensible; it was hard to fit in char limit. Can provide sample code if useful.

      In conversation about a year ago permalink
    • Embed this notice
      Paul Cantrell (inthehands@hachyderm.io)'s status on Thursday, 09-May-2024 02:37:06 JST Paul Cantrell Paul Cantrell
      in reply to
      • Andreas Hartl

      @_nd_ @nicklockwood
      AIUI, frozen vs non-frozen is about library evolution, not extensibility: it allows the library itself to add future cases without breaking existing code, but does not (I think?) allow library •clients• to add new cases. Both are useful. Def worth going over the difference if Nick decides to tackle it!

      In conversation about a year ago permalink
    • Embed this notice
      Andreas Hartl (_nd_@fnordon.de)'s status on Thursday, 09-May-2024 02:37:11 JST Andreas Hartl Andreas Hartl
      in reply to
      • Paul Cantrell

      @inthehands @nicklockwood on the other hand the difference beween frozen enums and non-frozen ones + @unknown default: is interesting from a library evolution perspective – compare and contrast ComparisonResult where three cases are all there ever will be and LABiometryType where Vision Pro added a new opticID case.

      In conversation about a year ago permalink

Feeds

  • Activity Streams
  • RSS 2.0
  • Atom
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.