Different ways of joining empty strings produce different results
Here are different ways to join empty strings. One may expect the results to be the same, but in reality, they give 3 different kind of answers. What is the rationale behind it?
join00 = join(string.empty(0,0), "/"); % 0x1 string
join01 = join(string.empty(0,1), "/"); % <missing>
join10 = join(string.empty(1,0), "/"); % <missing>
strjoin00 = strjoin(string.empty(0,0), "/"); % ""
strjoin10 = strjoin(string.empty(1,0), "/"); % ""
strjoin01 = strjoin(string.empty(0,1), "/"); % ""
Background
In my application, multiple series of strings are joined. Sometimes though, certain series is empty, in which case I am tasked to detect those results and replace them with "N/A". Through trial and error, I found that I cannot simply detect those results with only isempty(result), ismissing(result), or (isstring(result) || ischar(result)) && strlength(result) == 0, but I need the combination of all of them, which makes me wonder if there is any reason behind the different behavior.Here are different ways to join empty strings. One may expect the results to be the same, but in reality, they give 3 different kind of answers. What is the rationale behind it?
join00 = join(string.empty(0,0), "/"); % 0x1 string
join01 = join(string.empty(0,1), "/"); % <missing>
join10 = join(string.empty(1,0), "/"); % <missing>
strjoin00 = strjoin(string.empty(0,0), "/"); % ""
strjoin10 = strjoin(string.empty(1,0), "/"); % ""
strjoin01 = strjoin(string.empty(0,1), "/"); % ""
Background
In my application, multiple series of strings are joined. Sometimes though, certain series is empty, in which case I am tasked to detect those results and replace them with "N/A". Through trial and error, I found that I cannot simply detect those results with only isempty(result), ismissing(result), or (isstring(result) || ischar(result)) && strlength(result) == 0, but I need the combination of all of them, which makes me wonder if there is any reason behind the different behavior. Here are different ways to join empty strings. One may expect the results to be the same, but in reality, they give 3 different kind of answers. What is the rationale behind it?
join00 = join(string.empty(0,0), "/"); % 0x1 string
join01 = join(string.empty(0,1), "/"); % <missing>
join10 = join(string.empty(1,0), "/"); % <missing>
strjoin00 = strjoin(string.empty(0,0), "/"); % ""
strjoin10 = strjoin(string.empty(1,0), "/"); % ""
strjoin01 = strjoin(string.empty(0,1), "/"); % ""
Background
In my application, multiple series of strings are joined. Sometimes though, certain series is empty, in which case I am tasked to detect those results and replace them with "N/A". Through trial and error, I found that I cannot simply detect those results with only isempty(result), ismissing(result), or (isstring(result) || ischar(result)) && strlength(result) == 0, but I need the combination of all of them, which makes me wonder if there is any reason behind the different behavior. join, strjoin, string, empty MATLAB Answers — New Questions