Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -6,14 +6,15 @@ object Substring {
|
|||
|
||||
// Starting from n characters in and of m length
|
||||
assert("inspired by love" == str.slice(n, n + m))
|
||||
|
||||
// Starting from n characters in, up to the end of the string
|
||||
assert("inspired by love and guided by knowledge." == str.drop(n))
|
||||
|
||||
// Whole string minus last character
|
||||
assert("The good life is one inspired by love and guided by knowledge" == str.init)
|
||||
|
||||
// Starting from a known character within the string and of m length
|
||||
assert("life is one insp" == { val i = str.indexOf('l'); str.slice(i, i + m) })
|
||||
// Alternatively
|
||||
assert("life is one insp" == str.drop(str.indexOf('l')).take(m))
|
||||
assert("life is one insp" == str.dropWhile(_ != 'l').take(m) )
|
||||
|
||||
// Starting from a known substring within the string and of m length
|
||||
assert("good life is one" == { val i = str.indexOf("good"); str.slice(i, i + m) })
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue