空集文字语法
Empty Set literal syntax
寻找正确的语法或者是否有 bug/rough 优势:
Set{}
for empty hashes use '{} of KeyType => ValueType' <-wrong
Set{} of Char
expecting token '=>', not 'EOF' <-wrong
Set(Char){}
for empty hashes use '{} of KeyType => ValueType' <-wrong
Set(Char).new # not a literal
Set{'a'} # not an empty Set literal
没有,用Set(Char).new
。
设置字面量,比如Set{'a'}
实际编译为:
__tmp_var = Set(typeof('a')).new
__tmp_var << 'a'
__tmp_var
所以使用空文字而不是 Set(Char).new
没有性能优势
寻找正确的语法或者是否有 bug/rough 优势:
Set{}
for empty hashes use '{} of KeyType => ValueType' <-wrong
Set{} of Char
expecting token '=>', not 'EOF' <-wrong
Set(Char){}
for empty hashes use '{} of KeyType => ValueType' <-wrong
Set(Char).new # not a literal
Set{'a'} # not an empty Set literal
没有,用Set(Char).new
。
设置字面量,比如Set{'a'}
实际编译为:
__tmp_var = Set(typeof('a')).new
__tmp_var << 'a'
__tmp_var
所以使用空文字而不是 Set(Char).new