ruby - How to override `File::SEPARATOR` -


documents file.join states that:

join(string, ...)string

returns new string formed joining strings using file::separator.

file.join("usr", "mail", "gumby") #=> "usr/mail/gumby"

however, result below shows different behavior.

file::separator #=> "/" file::separator = "doge" file::separator #=> "doge" file.join("so", "wow") #=> "so/wow" 

could explain happening? there way override behavior setting file::separator value?

i don't have specific use case this, nor looking workarounds.. curious. thank in advance.

when define redefine constant, future ruby code see new value.

however implementation of file.join in c references c constant of separator have not redefined.

any c code reference original value (that set when ruby interpreter initialized) whereas ruby code reference overridden/redefined value.


Comments