mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
* stash * Use rejectif idea * rename * wip! * Convert old systems to new * fixup! * fix typo
This commit is contained in:
21
pkg/rejectif/ultimate.go
Normal file
21
pkg/rejectif/ultimate.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package rejectif
|
||||
|
||||
/*
|
||||
I proposed that Go add something like "len()" that returns the highest
|
||||
index. This would avoid off-by-one errors. The proposed names include
|
||||
ultimate(), ult(), high(), highest().
|
||||
|
||||
Nay-sayers said I should implement this as a function and see if I
|
||||
actually used it. (I suspect the nay-sayers are perfect people that
|
||||
never make off-by-one errors.)
|
||||
|
||||
That's what this file is about. It should be exactly the same (except
|
||||
the first line) anywhere this is needed. After a few years I'll be
|
||||
able to report if it actually helped.
|
||||
|
||||
Go will in-line this function.
|
||||
*/
|
||||
|
||||
func ultimate(s string) int {
|
||||
return len(s) - 1
|
||||
}
|
Reference in New Issue
Block a user