diff options
author | Rob Pike <r@golang.org> | 2014-12-23 08:00:39 +1100 |
---|---|---|
committer | Andrew Gerrand <adg@golang.org> | 2014-12-22 21:29:20 +0000 |
commit | b35b5e35dbb795b8392180ed8b008a2e245e55cf (patch) | |
tree | 9aca99b60fb92a1ae1b0ac3fd1bedfc71800f8a3 | |
parent | 5216eb88db404941ccc701ca323591b5af3178b4 (diff) |
generate: update to new stringer format
During code review for this post, dsymonds noticed a way to simplify
the generated code. That simplification is now checked in, so bring the
post up to date.
Change-Id: If29587332c8cc210ecac4843e9dd45dfa01118f7
Reviewed-on: https://go-review.googlesource.com/2020
Reviewed-by: Andrew Gerrand <adg@golang.org>
-rw-r--r-- | content/generate.article | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/content/generate.article b/content/generate.article index a918ba7..ea742e1 100644 --- a/content/generate.article +++ b/content/generate.article @@ -153,18 +153,13 @@ Let's run it: const _Pill_name = "PlaceboAspirinIbuprofenParacetamol" - var _Pill_index = [...]uint8{7, 14, 23, 34} + var _Pill_index = [...]uint8{0, 7, 14, 23, 34} func (i Pill) String() string { if i < 0 || i >= Pill(len(_Pill_index)) { return fmt.Sprintf("Pill(%d)", i) } - hi := _Pill_index[i] - lo := uint8(0) - if i > 0 { - lo = _Pill_index[i-1] - } - return _Pill_name[lo:hi] + return _Pill_name[_Pill_index[i]:_Pill_index[i+1]] } $ |