Code as given can be made valid in scala I believe. My starter was based on that assumption. I think raku can do it too, but you would probably have to x = $ to make it work…
Edit: misread your comment slightly, CBA to change mine now. It is what it is