3

As an iOS developer, I see a lot of old answers in Objective-C, often accompanied with new Swift version, which may be in many different Swift versions too (Swift 2, Swift 3, etc.)

I'm sure this is not the only example, as there are Java and Kotlin in Android questions (and not just them), Gradle/Gradle KTS, etc. And I believe in future there'll be more of such examples.

I think that answer syntax should adopt to it. In most of modern documentations you can switch between Swift and Objective-C (e.g., developers.google.com), and I think in the same way it should be possible to switch between language variants on posts (if there're some). User should be able to specify preferred languages that should be selected in such cases.

Existing examples of this kind of feature:

From Google Developer documentation:

Enter image description here

From Symfony's documentation:

Enter image description here

I'm not very good in Markdown, so maybe I've reinventing something that already exists, but as we can specify language like

```swift
code
```

Probably we could've use something like

```swift
swift code
```obj-c
obj-c code
```

I'm not sure how hard is it to implement the new design for such feature, but seems like something we should have.


This is indeed a duplicate of add-a-means-for-tab-stacking-code-snippets. I haven't found it by myself. Sadly it's still open after six years and looks like it doesn't have enough attention.

4
  • 2
    The code fences already support defining the language; I'm not sure what the problem is here apart from that in your second attempt you forgot to close the code fence before you started the next one.
    – Thom A
    Aug 6, 2021 at 12:20
  • @Larnu I think this is actually a FR to have tabbed view when it's possible to express equivalent things in multiple languages. Something like this. Or like this example they link to in the question. Having an actual screenshot without having to click a link would have been helpful...
    – yivi
    Aug 6, 2021 at 12:34
  • ... and if you intended to do that, please don't. Multiple languages in a single fence is gonna cause several annoyances, and it'll be a nightmare to parse
    – Zoe Mod
    Aug 6, 2021 at 12:34
  • 1
    A bit simpler solution would be to enable collapsing code blocks, but unfortunately this was declined previously.
    – Marijn
    Aug 6, 2021 at 12:45

0

Browse other questions tagged .