Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent of array join() for Set in Ruby?

Tags:

arrays

ruby

set

Is there an equivalent of array join() for the Set class in Ruby? or best to just monkey patch my own on the Set class?

http://ruby-doc.org/stdlib-2.2.2/libdoc/set/rdoc/Set.html

like image 503
wired00 Avatar asked May 02 '15 04:05

wired00


1 Answers

What is wrong with set.to_a.join?

Something to keep in mind: The documentation says that a "Set implements a collection of unordered values with no duplicates." That means the order is not guaranteed. For the to_a method the documentation tells you that "the order of elements is uncertain".

I am not sure if a join makes sense with this circumstances...

like image 61
spickermann Avatar answered Oct 18 '22 08:10

spickermann