Interestingly, C and C++ have a mechanism that can often solve this problem: const. You can define arguments as being const, i.e. unchangeable:
In Java, I would spell that as wordcount(ImmutableList.of(words)), and then get a runtime error when the function tries to modify the list.
wordcount(ImmutableList.of(words))
Not ideal; merely workable.
In Java, I would spell that as
wordcount(ImmutableList.of(words)), and then get a runtime error when the function tries to modify the list.Not ideal; merely workable.