This is probably intentional, but IMO it's messy:
class Foo
def x(arg = 10)
return arg
end
end
foo = Foo.new
m = 1
x = 10
x / 2/m # => 5
x /2/m # => 5
foo.x / 2/m # => 5
foo.x /2/m # => /2/m
foo.x/2/m # => 5
foo.x/ 2 # => 5
foo.x / 2 # => 5
#foo.x /2 # unterminated regular expression
For consistency, I think / should always signify division when used immediately after tokens that constitute or terminate expressions (i.e. the only places infix operators make sense) and a Regex literal after any other tokens (left-delimiters like ([{, commas or mathematical operators, conditional keywords such as if) or at the beginning of a statement.
This would break a lot of uses of String#match (many of which could be replaced with =~) and String#gsub (which would need added parentheses or a different Regex syntax) but it would make the language grammar and lexing slightly saner.
IMO binary operators - at least those that can be ambiguous (/+-) - should generally be surrounded with whitespace.
See also #5411
The language works pretty much like Ruby. I think that's fine.
Most helpful comment
IMO binary operators - at least those that can be ambiguous (
/+-) - should generally be surrounded with whitespace.See also #5411