From 6c9db58c76b31424276cb70595c5208aa6c015ae Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Wed, 6 Mar 2019 18:37:20 -0700 Subject: Add ListBuilder.Len() This commit adds a method to check the current length of a list on a `ListBuilder`. This allows the length to be checked without marking the next builder change as immutable. --- immutable.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'immutable.go') diff --git a/immutable.go b/immutable.go index e8fac90..c1a8aef 100644 --- a/immutable.go +++ b/immutable.go @@ -246,6 +246,11 @@ func (b *ListBuilder) List() *List { return list } +// Len returns the number of elements in the underlying list. +func (b *ListBuilder) Len() int { + return b.list.Len() +} + // Get returns the value at the given index. Similar to slices, this method will // panic if index is below zero or is greater than or equal to the list size. func (b *ListBuilder) Get(index int) interface{} { -- cgit v1.2.3