Ruby Abbreviation Contents

Asked 2 years ago, Updated 2 years ago, 41 views

Trying abbreviations

array1=%w[Yes]
array2 = ["A", "I", "U"]
puts array==array2

false returned after running .
If I use abbreviation, will the contents change?

ruby

2022-09-30 19:39

2 Answers

For ruby (at least MRI), any string that can have a special syntactic meaning appears to be ASCII characters.(parse.y is written using functions defined in the link below)

https://github.com/ruby/ruby/blob/a8812080c4977c2731e8ff1b129b59d236bc12e3/include/ruby/ruby.h#L2220

In that sense, full-width spaces are not given any particular syntactic meaning, so it seems that ruby's parsing was working as one string or .(So finally array1 appears to have been parsed as an array of length 1 called ["you"])

Other than that, it's just as someone else explained.


2022-09-30 19:39

array1=%w[Yes]
array2 = ["A", "I", "U"]
puts array1 == array2
# = > true

https://paiza.io/projects/IFZhiTCoZj-dFF_-crCK7A
is now


2022-09-30 19:39

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.