# Ruby-dev summary 26385-26467

**URL:** <https://rubytalk.org/t/ruby-dev-summary-26385-26467/19595>\
**Category:** ruby-talk\
**Created:** [18 July 2005 16:30 UTC](https://rubytalk.org/t/ruby-dev-summary-26385-26467/19595 "2005-07-18T16:30:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Berger\_Daniel1](https://avatars.discourse-cdn.com/v4/letter/b/ecc23a/32.png) [@Berger\_Daniel1](https://rubytalk.org/u/Berger_Daniel1)\
**Post date:** [18 July 2005 16:30 UTC](https://rubytalk.org/t/ruby-dev-summary-26385-26467/19595/1 "2005-07-18T16:30:49Z")

</div>

> From: Ryan Leavengood [mailto:mrcode@netrox.net]  
> Sent: Monday, July 18, 2005 9:58 AM  
> To: ruby-talk ML  
> Subject: Re: ruby-dev summary 26385-26467
> 
> Berger, Daniel said:  
> \>  
> \> What about simply altering String#to\_a?  
> \>  
> \> String#to\_a(bytes=false)  
> \> Returns the string as an array of characters, or bytes if the  
> \> +bytes+ argument is true.
> 
> I \*strongly\* dislike parameterizing methods like this. If you  
> are going to fundamentally alter the behavior of a method,  
> just make a new method. That way the new behavior is explicit.
> 
> If I read this code:
> 
> "str".to\_a(true)
> 
> I will probably have to read the documentation for to\_a to  
> figure out what the true means. Whereas this:
> 
> "str".to\_bytes # Or whatever it is called
> 
> is essentially self-documenting.

Generally speaking I agree with you, but I also try to weigh that  
consideration against API bloat. And, since the default (false) is  
probably what most people would use most of the time, it's a bullet I'd  
be willing to bite. However, all of this probably academic, as you  
mention below.

> \> I've never really liked the current implementation, where  
> "foo".to\_a  
> \> merely becomes ["foo"] - it just isn't useful usually.  
> However, I'm  
> \> also aware that modifying String#to\_a could cause major  
> breakage for  
> \> many current packages (mine included). Is it worth it?  
> I'll let Matz  
> \> decide.
> 
> The usefulness of the current String#to\_a is certainly  
> debateable, but changing it is definitely too big of a change  
> to be viable.
> 
> Ryan

Yes, probably. Plus, Matz tends to dissuade folks from thinking of  
strings as an array of characters, even though we're constantly breaking  
down strings into arrays of characters. 😉

Well, there's always Sydney. 🙂

Regards,

Dan

> **···**
>
> > -----Original Message-----

---

<div class="post-metadata">

**Author:** ![Ara.T.Howard6](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@Ara.T.Howard6](https://rubytalk.org/u/Ara.T.Howard6)\
**Post date:** [18 July 2005 17:38 UTC](https://rubytalk.org/t/ruby-dev-summary-26385-26467/19595/2 "2005-07-18T17:38:18Z")

</div>

you can always have the best of both worlds with something like

&nbsp;&nbsp;&nbsp;"string".to\_a 'bytes' =\> true

the beauty of this sort of api is that later you can add

&nbsp;&nbsp;&nbsp;"string".to\_a 'bytes' =\> true, 'unicode' =\> true

and break nothing.

cheers.

-a

> **···**
>
> On Tue, 19 Jul 2005, Berger, Daniel wrote:
> 
> > > -----Original Message-----  
> > > From: Ryan Leavengood [mailto:mrcode@netrox.net]  
> > > Sent: Monday, July 18, 2005 9:58 AM  
> > > To: ruby-talk ML  
> > > Subject: Re: ruby-dev summary 26385-26467
> > > 
> > > Berger, Daniel said:
> > > 
> > > > What about simply altering String#to\_a?
> > > > 
> > > > String#to\_a(bytes=false)  
> > > > &nbsp;&nbsp;&nbsp;Returns the string as an array of characters, or bytes if the  
> > > > +bytes+ argument is true.
> > > 
> > > I \*strongly\* dislike parameterizing methods like this. If you  
> > > are going to fundamentally alter the behavior of a method,  
> > > just make a new method. That way the new behavior is explicit.
> > > 
> > > If I read this code:
> > > 
> > > "str".to\_a(true)
> > > 
> > > I will probably have to read the documentation for to\_a to  
> > > figure out what the true means. Whereas this:
> > > 
> > > "str".to\_bytes # Or whatever it is called
> > > 
> > > is essentially self-documenting.
> > 
> > Generally speaking I agree with you, but I also try to weigh that  
> > consideration against API bloat. And, since the default (false) is  
> > probably what most people would use most of the time, it's a bullet I'd  
> > be willing to bite. However, all of this probably academic, as you  
> > mention below.
> 
> # --
> 
> > email :: ara [dot] t [dot] howard [at] noaa [dot] gov  
> > phone :: 303.497.6469  
> > My religion is very simple. My religion is kindness.  
> > --Tenzin Gyatso
> 
> ===============================================================================
