6

As you all probably know switch has been introduced in Summer'18 (API v43,0) release.

I have started using it in my apex class which is having API version 36,0 and somehow it works in my sandbox. I was assuming it wouldn't be available hence throw an error or something like that.

My question is, is that a reliable/intended behavior or should I switch to API version 43,0 before deploying to production just to be on the safe side?

2 Answers 2

6

Switch is not a versioned feature, presumably because they didn't want to force developers to upgrade to the latest API just to take advantage of this (and potentially trigger a large number of other required changes). As I've said before (in a another answer on this site), consider keeping all your classes the same version to avoid bugs. Only upgrade your API version when you have time to commit to a full upgrade/regression testing cycle.

2
  • 2
    It seems like most of the versioned changes relate to object definitions rather than code (e.g. trying to use Platform Events in a too-early version).
    – Adrian Larson
    Commented Jul 18, 2018 at 19:10
  • Keeping all classes at the same version was the exact reason for me to ask this since I don't want to (at least not yet) invest my time to upgrade/test 100+ classes. Also another thanks for 'versioned features/changes'. Seems like I have some research to do.
    – Lafexlos
    Commented Jul 18, 2018 at 20:25
4

I've noticed the same thing and can only assume that while there is a versioning layer in APIs, the compiler may just always grow its syntax and not shrink its syntax. Or it could be that there is a versioning mechanism there and the addition of that logic has just been missed.

I've moved to version 43.0 to be on the safe side.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .