mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
[DOC] Enhanced RDoc for String (#5724)
Treats: #scan #hex #oct #crypt #ord #sum
This commit is contained in:
parent
ca85f16a7d
commit
d52cf1013f
Notes:
git
2022-03-28 04:45:44 +09:00
Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
3 changed files with 74 additions and 46 deletions
6
doc/string/ord.rdoc
Normal file
6
doc/string/ord.rdoc
Normal file
|
@ -0,0 +1,6 @@
|
|||
Returns the integer ordinal of the first character of +self+:
|
||||
|
||||
'h'.ord # => 104
|
||||
'hello'.ord # => 104
|
||||
'тест'.ord # => 1090
|
||||
'こんにちは'.ord # => 12371
|
11
doc/string/sum.rdoc
Normal file
11
doc/string/sum.rdoc
Normal file
|
@ -0,0 +1,11 @@
|
|||
Returns a basic +n+-bit checksum of the characters in +self+;
|
||||
the checksum is the sum of the binary value of each byte in +self+,
|
||||
modulo <tt>2**n - 1</tt>:
|
||||
|
||||
'hello'.sum # => 532
|
||||
'hello'.sum(4) # => 4
|
||||
'hello'.sum(64) # => 532
|
||||
'тест'.sum # => 1405
|
||||
'こんにちは'.sum # => 2582
|
||||
|
||||
This is not a particularly strong checksum.
|
Loading…
Add table
Add a link
Reference in a new issue