Skip to content

Commit 1edd8d0

Browse files
committed
Handle empty and scalar cases in string conversion
Fixed string conversion for empty objects to return empty string Add extra step in ControlledTerm to ensure scalar string "" is treated as empty
1 parent eca1a2e commit 1edd8d0

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

code/internal/+openminds/+abstract/ControlledTerm.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
propValues.id (1,1) string
5151
end
5252

53+
if isstring(instanceSpec) && isscalar(instanceSpec) && instanceSpec == ""
54+
instanceSpec = string.empty;
55+
end
56+
5357
if ~isempty(instanceSpec)
5458
if ischar(instanceSpec)
5559
instanceSpec = string(instanceSpec);

code/internal/+openminds/+internal/+mixin/CustomInstanceDisplay.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@
3030
end
3131

3232
function str = string(obj)
33-
if numel(obj) > 1
34-
str = strjoin( arrayfun(@(x) string(x.DisplayString), obj ), '; ');
35-
else
33+
if isempty(obj)
34+
str = string.empty;
35+
elseif isscalar(obj)
3636
str = string( obj.DisplayString );
37+
else
38+
str = strjoin( arrayfun(@(x) string(x.DisplayString), obj ), '; ');
3739
end
3840
end
3941

0 commit comments

Comments
 (0)