mkodekar / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Joiner accepts distinct last separator #1794

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It would be nice to have something like:
Joiner.on(", ",  " and ").join("Blueberry", "Orange", "Lime", "Guava");  //=> 
"Blueberry, Orange, Lime and Guava"
or even:
Joiner.on(", ").lastSeparator(" and ").join("Blueberry", "Orange", "Lime", 
"Guava");  //=> "Blueberry, Orange, Lime and Guava"

Original issue reported on code.google.com by bermon...@gmail.com on 30 Jun 2014 at 5:49

GoogleCodeExporter commented 9 years ago
Joiner is really just supposed to be a simple utility (debugging, etc.). If 
you'd going to be rendering content for user consumption and need to take 
internationalization and sentence structure into account, Joiner really isn't 
the right tool IMO.

Original comment by kak@google.com on 30 Jun 2014 at 5:55

GoogleCodeExporter commented 9 years ago
Agreed, but it would be a time saver for small projects. Since it's a class 
specialized in joining, adding such a method wouldn't hurt the API so much IMO. 

Original comment by bermon...@gmail.com on 6 Jul 2014 at 12:24

GoogleCodeExporter commented 9 years ago
I'm gonna go ahead and say this isn't something we want to do. There are all 
kinds of edge case features Joiner *could* handle, but it's designed to do one 
simple thing and each added feature really does complicate the API. This 
particular request also feels a little too specific to English/western 
languages to me.

Original comment by cgdecker@google.com on 7 Jul 2014 at 4:43

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<issue id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:08

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:07