• atzanteol@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    3
    ·
    7 days ago

    With OOP languages, class methods can create a dichotomy of expected returns: Using a list reversal as an example, will a list.reverse(some_list) function reverse the list in-place, or return a copy of the reversed list and leave the original in-tact?

    Mmm - that is an excellent example, though not one specific to OOP… But I see your point. I think Kotlin and other languages have addressed these types of issues with ‘mutability’ as part of the type where it becomes explicit which variables can be modified. Kotlin even has “MutableList” as distinct from “List” which lets you say whether a list’s contents can be modified.