Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,12 @@ def tsort_each_child(node, &block)
end
end

# Returns a string created by converting each element of the set to a string
# See also: Array#join
def join(separator=nil)
to_a.join(separator)
end

InspectKey = :__inspect_key__ # :nodoc:

# Returns a string containing a human-readable representation of the
Expand Down
5 changes: 5 additions & 0 deletions test/test_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,11 @@ def test_freeze_clone_false
assert_equal Set[1,2,3], set1
end if Kernel.instance_method(:initialize_clone).arity != 1

def test_join
assert_equal('123', Set[1, 2, 3].join)
assert_equal('1 & 2 & 3', Set[1, 2, 3].join(' & '))
end

def test_inspect
set1 = Set[1, 2]
assert_equal('#<Set: {1, 2}>', set1.inspect)
Expand Down