Abbrev
计算为一组给定的字符串集的独特的缩写,也就是。
require 'abbrev'
require 'pp'
pp Abbrev.abbrev(['ruby', 'rules'])
结果:
{ "rub" => "ruby",
"ruby" => "ruby",
"rul" => "rules",
"rule" => "rules",
"rules" => "rules" }
它也提供了一个数组方法的扩展,Array#abbrev
pp %w{summer winter}.abbrev
#=> {"summe"=>"summer",
"summ"=>"summer",
"sum"=>"summer",
"su"=>"summer",
"s"=>"summer",
"winte"=>"winter",
"wint"=>"winter",
"win"=>"winter",
"wi"=>"winter",
"w"=>"winter",
"summer"=>"summer",
"winter"=>"winter"}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。