refinement.rb

Ruby마스터

탐색기

C40
C++40
C#40
Dart40
Go40
Java40
JavaScript40
Kotlin40
Objective-C40
Perl40
PHP40
Python40
R40
Ruby
초급10
중급10
고급10
전문가5
마스터5
meta_dsl.rb
fiber_pool.rb
concern_module.rb
refinement.rb
middleware.rb
Rust40
Shell40
Swift40
TypeScript40
refinement.rb
Click to focus
1
2
3
4
5
6
7
8
9
10
11
12
13
module StringExt
 refine String do
   def words
     scan(/\w+/).map(&:downcase)
   end
   def similarity(other)
     a, b = words, other.words
     (a & b).size.to_f / (a | b).size
   end
 end
end
using StringExt
"hello world".similarity("world")
0WPM0%0:000/247(0%)|Ln 1, Col 1
UTF-8Ruby

관련 연습 문제