groovy

provide size() on StringBuffer

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.0-JSR-2
  • Fix Version/s: 1.0-JSR-3
  • Component/s: groovy-jdk
  • Labels:
    None
  • Testcase included:
    yes
  • Number of attachments :
    0

Description

Strings, List, etc. all have a GDK method size() but StringBuffer only has 'getSize()' or 'size' respectively

x = new StringBuffer()
assert x.size() == x.size
x = new StringBuffer('some text')
assert x.size() == x.size

Activity

Hide
Wang Bin added a comment -

Maybe size() name is not suitable. JDK has another name length() to Returns the length (character count) of this string buffer.

Show
Wang Bin added a comment - Maybe size() name is not suitable. JDK has another name length() to Returns the length (character count) of this string buffer.
Hide
Dierk Koenig added a comment -

the JDK has all kinds of different method and field names to determine a size.
Groovy has one standard: the size() method

Show
Dierk Koenig added a comment - the JDK has all kinds of different method and field names to determine a size. Groovy has one standard: the size() method
Hide
Russel Winder added a comment -

If we are saying that this is "Not a Bug" and "Not a Desired Extension" then I guess we should close this item.

Show
Russel Winder added a comment - If we are saying that this is "Not a Bug" and "Not a Desired Extension" then I guess we should close this item.
Hide
Dierk Koenig added a comment -

for me it is a desired extension.

The GDK is to enhance the JDK.

A simple example is the size() method as used in the GDK. It is equally available on everything that is of some size: Strings, arrays, Lists, Maps, and other collections although - behind the scenes - they are all JDK Classes. This is an improvement over the JDK where you need to determine the size in a number of different ways:

  • by referring to the length field (for arrays) or
  • by calling java.lang.reflect.Array.getLength(array),
  • by calling the length() method (for Strings), or
  • by calling the size() method (for java.util.Collections).
    The GDK solution is more consistent and easier to remember.
    Except that it is not available on StringBuffer.
Show
Dierk Koenig added a comment - for me it is a desired extension. The GDK is to enhance the JDK. A simple example is the size() method as used in the GDK. It is equally available on everything that is of some size: Strings, arrays, Lists, Maps, and other collections although - behind the scenes - they are all JDK Classes. This is an improvement over the JDK where you need to determine the size in a number of different ways:
  • by referring to the length field (for arrays) or
  • by calling java.lang.reflect.Array.getLength(array),
  • by calling the length() method (for Strings), or
  • by calling the size() method (for java.util.Collections). The GDK solution is more consistent and easier to remember. Except that it is not available on StringBuffer.
Hide
Dierk Koenig added a comment -

closed after final discussion on mailinglist

Show
Dierk Koenig added a comment - closed after final discussion on mailinglist
Hide
Russel Winder added a comment -

I guess we should say what the outcome was in summary here for completeness of this issue as a record. I would do it but I have forgotten what the outcome was!

Show
Russel Winder added a comment - I guess we should say what the outcome was in summary here for completeness of this issue as a record. I would do it but I have forgotten what the outcome was!
Hide
Dierk Koenig added a comment -

after final discussion, size() was implemented.

Show
Dierk Koenig added a comment - after final discussion, size() was implemented.
Hide
Dierk Koenig added a comment -

done

Show
Dierk Koenig added a comment - done

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: