When do you use Sketchup::Set instead of the ruby Set?
Sketchup::Set - we should have marked it as deprecated. The Ruby
Set class is much faster and much better implemented. It was kept around in the
Sketchup module simply for backwards compatibility with older projects.
I was looking for a reason why I should use Sketchup::Set instead of the ruby Set. I thought there must be a reason for its existence, but there is no. Ok thats clear to me.
There are some differences in the names of methods.
I did a write up on it somewhere (probably SketchUcation.)
Sorry to revive this old thread. I have the same question as the OP. If I look at the API docs (link below) - its a bit confusing and the example code throws an error.
In the first line of the link, it states in 2014 it was changed from
SketchUp::Set and next it states we should use the
Set class because
SketchUp::Set is deprecated?!
If you try the example code from that page
set = Set.new
the last line throws an error…
Confused - where can I find the correct information on using a Set in SketchUp?
This discussion is talking about
require 'set' versus classes introduced by SketchUp (
Set which later was moved to
SketchUp 2014 introduced a new version of Ruby and decided to ship also Ruby’s standard library (all what you require before using). This would have caused a name clash if not moving SketchUp’s own
Set. On the other side, it became way easier to use the (better) implementation of
Set from Ruby, because developers would not have to download it elsewhere and package it with their plugin.
As Dan mentioned, methods are named differently, and the deprecation message means not to use this page, but the documentation of Ruby’s Set. So the example becomes:
require 'set' # At the beginning of the file set = Set.new set.add('Hello') set.include?('你好')
Thanks for the clarification. I think I need more coffee today…
Thanks for the links Dan.