Re: char to string ????

From: Phil... (rynes_at_ieee.org)
Date: 10/28/03


Date: Tue, 28 Oct 2003 22:16:38 GMT

doesn't c++ overload + for strings

"Glen Herrmannsfeldt" <gah@ugcs.caltech.edu> wrote in message
news:JEBnb.52612$e01.129874@attbi_s02...
>
> "Phil..." <rynes@ieee.org> wrote in message
> news:6xxnb.49857$Fm2.24685@attbi_s04...
> > my book says left to right also
> >
> > "Glen Herrmannsfeldt" <gah@ugcs.caltech.edu> wrote in message
>
> (snip)
>
> > > I thought it would evaluate left to right, so String s = b + a + d +
"";
> > > would be equivalent to
> > >
> > > String s = ((( b + a ) + d ) + ""; which is not what was asked for.
If
> > >you put the "" first it should work, though.
>
> > > You can also create a StringBuffer, add the chars one at a time, and
> then
> > > make a String from it.
>
> I did test it with char's before "" and it does add the value instead of
> concatenating as strings, as left to right says it should.
>
> My favorite was something like:
>
> System.out.println( 2 + "+" +2+" equals " +2+2);
>
> Personally, I think overloading the + operator was a bad idea. Notice
that
> Java doesn't allow user operator overloading, as users might apply
operators
> in confusing ways. Then again, the PL/I string concatenation operator,
||,
> was already taken.
>
> The awk concatenation operator, nothing at all, might have worked, though.
>
> -- glen
>
>



Relevant Pages

  • Re: string concatenation optimizations [from python-dev Summary]
    ... Essentially what I have in mind is a type that's a list of byte ... The value is defined as the concatenation of these arrays. ... > way to concatenate a bunch of strings. ...
    (comp.lang.python)
  • Re: why use the data command parameter collection
    ... cumbersome than using an iterative object oriented approach. ... quote characters or other such input by concatenating strings. ... Parameters Collection. ... Also the approach string concatenation leaves a lot to be desired (see ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: From D
    ... string concatenation and allow numeric literals to implicitly concatenate? ... Did you miss the bit where Python ALREADY does this for strings? ... because two int tokens can be "concatenated" to make a single int token, ...
    (comp.lang.python)
  • Re: deepening into fortran 90,95, 2003
    ... I've been bitten many times by the slowness of concatenation of strings. ... Support the Original G95 Project: http://www.g95.org ... Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html ...
    (comp.lang.fortran)
  • Re: concat vs variable in string
    ... Or does it still do a concatenation behind the scenes? ... If you use single quotes instead of double, ... massive strings or a long loop. ... to be wrapped in double quoted strings, ...
    (comp.lang.php)