Czy jest lepszy sposób niż poniższy, aby sprawdzić, czy łańcuch jest zerowy LUB ma długość 0 w Rubim?
if !my_string || my_string.length == 0
return true
else
return false
end
W C # jest poręczny
string.IsNullOrEmpty(myString)
Coś podobnego do tego w Rubim?
my_string || my_string.length == 0podniesie NoMethodErrorjeśli my_stringjest zero. Myślę, że miałeś na myśli:my_string.nil? || my_string.length == 0
!my_string || my_string.length == 0