File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -574,15 +574,16 @@ def deconstruct; valid? ? [normalized_string] : [] end
574
574
# Use #add, #merge, or #append to add a string to an existing set.
575
575
#
576
576
# Related: #replace, #clear
577
- def string = ( str )
578
- if str . nil?
577
+ def string = ( input )
578
+ if input . nil?
579
579
clear
580
- else
581
- modifying! # redundant check, to normalize the error message for JRuby
582
- str = String . try_convert ( str ) or raise ArgumentError , "not a string"
580
+ elsif ( str = String . try_convert ( input ) )
581
+ modifying! # short-circuit before parsing the string
583
582
tuples = str_to_tuples str
584
583
@tuples , @string = [ ] , -str
585
584
tuples_add tuples
585
+ else
586
+ raise ArgumentError , "expected a string or nil, got #{ input . class } "
586
587
end
587
588
str
588
589
end
You can’t perform that action at this time.
0 commit comments