[#349422] Date.parse('17:26:33 Oct 31, 2009') returns invalid date — Jacob Gorban <jacob.gorban@...>

Hi,

13 messages 2009/11/01

[#349519] All Gems Down? — Joshua Ballanco <jballanc@...>

I think I must be the only one using allgems.ruby-forum.com. It seems

17 messages 2009/11/03

[#349527] Ruby Inline over two times slower under 1.9 than under 1.8? — "Shot (Piotr Szotkowski)" <shot@...>

I=E2=80=99m starting to dip my toes in non-Ruby coding (for performance rea=

13 messages 2009/11/03
[#349564] Re: Ruby Inline over two times slower under 1.9 than under 1.8? — Ryan Davis <ryand-ruby@...> 2009/11/03

[#350186] Re: Ruby Inline over two times slower under 1.9 than under 1.8? — "Shot (Piotr Szotkowski)" <shot@...> 2009/11/11

Ryan Davis:

[#350196] Re: Ruby Inline over two times slower under 1.9 than under 1.8? — Roger Pack <rogerpack2005@...> 2009/11/11

> — Shot, who’s off to play with RubyToC now. :)

[#350228] Re: Ruby Inline over two times slower under 1.9 than under 1.8? — "Shot (Piotr Szotkowski)" <shot@...> 2009/11/11

Roger Pack:

[#349640] Odd : a = Hash.new(Hash.new) — Aldric Giacomoni <aldric@...>

irb(main):086:0> a = Hash.new(Hash.new)

13 messages 2009/11/04
[#349641] Re: Odd : a = Hash.new(Hash.new) — Aldric Giacomoni <aldric@...> 2009/11/04

Aldric Giacomoni wrote:

[#349685] Create HTML files using RUBY — Krithika San <skrithikaa@...>

Hi,

23 messages 2009/11/04
[#349690] Re: Create HTML files using RUBY — Marnen Laibow-Koser <marnen@...> 2009/11/04

Krithika San wrote:

[#349691] Re: Create HTML files using RUBY — Krithika San <skrithikaa@...> 2009/11/04

Hi Marnen,

[#349692] Re: Create HTML files using RUBY — Marnen Laibow-Koser <marnen@...> 2009/11/04

Krithika San wrote:

[#349720] Executing one of several ruby objects — "dhf0820@..." <dhf0820@...>

I am trying to write a program that will load a series of DSLs (ruby

11 messages 2009/11/05

[#349849] RCR enumerable extra into core — Roger Pack <rogerpack2005@...>

I'm considering suggesting that the base functionality for the

25 messages 2009/11/08
[#349853] Re: RCR enumerable extra into core — "David A. Black" <dblack@...> 2009/11/08

Hi --

[#349996] Re: RCR enumerable extra into core — Roger Pack <rogerpack2005@...> 2009/11/09

[#349888] Using Nokogiri — jzakiya <jzakiya@...>

I'm trying to scrape some data off websites using nokogiri

18 messages 2009/11/08

[#349926] FileString - request for comments — apeiros@...

Hi there

15 messages 2009/11/09
[#349931] Re: FileString - request for comments — James Edward Gray II <james@...> 2009/11/09

On Nov 8, 2009, at 7:47 PM, apeiros@gmx.net wrote:

[#349987] Berkeley DB BDB Install on Windows — david <davidhooey@...>

I've been scripting in Ruby (and Rails) for about two years now, but

14 messages 2009/11/09

[#350007] Good or best way to allocate a large array — Ralph Shnelvar <ralphs@...32.com>

Newbie here:

45 messages 2009/11/09
[#350017] Re: Good or best way to allocate a large array — Marnen Laibow-Koser <marnen@...> 2009/11/09

Ralph Shnelvar wrote:

[#350019] Re: Good or best way to allocate a large array — Ralph Shnelvar <ralphs@...32.com> 2009/11/09

Marnen,

[#350023] Re: Good or best way to allocate a large array — Marnen Laibow-Koser <marnen@...> 2009/11/09

Ralph Shnelvar wrote:

[#350029] Re: Good or best way to allocate a large array — Ralph Shnelvar <ralphs@...32.com> 2009/11/09

Marnen,

[#350042] Re: Good or best way to allocate a large array — "Florian Frank" <flori@...> 2009/11/09

Ralph Shnelvar wrote:

[#350045] Re: Good or best way to allocate a large array — Ralph Shnelvar <ralphs@...32.com> 2009/11/09

Florian,

[#350047] Re: Good or best way to allocate a large array — Rick DeNatale <rick.denatale@...> 2009/11/09

On Mon, Nov 9, 2009 at 5:46 PM, Ralph Shnelvar <ralphs@dos32.com> wrote:

[#350048] Re: Good or best way to allocate a large array — Ralph Shnelvar <ralphs@...32.com> 2009/11/10

Rick,

[#350053] Re: Good or best way to allocate a large array — Florian Gilcher <flo@...> 2009/11/10

Hi,

[#350142] Calling a subprocess with specific arguments and capturing its output? — Dan Q <quinxex@...>

Hi. I haven't written Ruby in a while, and I was wondering if someone

9 messages 2009/11/10

[#350147] Roman Numerals (Arrgh!) — Rick Barrett <chngth3wrld@...>

I have a homework assignment where I have to convert an inputted integer

22 messages 2009/11/10
[#350150] Re: Roman Numerals (Arrgh!) — Rob Biedenharn <Rob@...> 2009/11/11

On Nov 10, 2009, at 6:56 PM, Rick Barrett wrote:

[#350152] Re: Roman Numerals (Arrgh!) — Gennady Bystritsky <Gennady.Bystritsky@...> 2009/11/11

On Nov 10, 2009, at 5:37 PM, Rob Biedenharn wrote:

[#350156] Re: Roman Numerals (Arrgh!) — Rob Biedenharn <Rob@...> 2009/11/11

On Nov 10, 2009, at 8:49 PM, Gennady Bystritsky wrote:

[#350159] Re: Roman Numerals (Arrgh!) — Gennady Bystritsky <Gennady.Bystritsky@...> 2009/11/11

[#350290] DRYing a Regex — RichardOnRails <RichardDummyMailbox58407@...>

I've got a routine that works fine at building an array of upper-case

42 messages 2009/11/12
[#350311] Re: DRYing a Regex — RichardOnRails <RichardDummyMailbox58407@...> 2009/11/13

On Nov 12, 6:50=A0pm, James Edward Gray II <ja...@graysoftinc.com>

[#350367] Naming conventions -- was: Re: DRYing a Regex — Marnen Laibow-Koser <marnen@...> 2009/11/14

RichardOnRails wrote:

[#350368] Re: Naming conventions -- was: Re: DRYing a Regex — James Edward Gray II <james@...> 2009/11/14

On Nov 13, 2009, at 10:11 PM, Marnen Laibow-Koser wrote:

[#350369] Re: Naming conventions -- was: Re: DRYing a Regex — Marnen Laibow-Koser <marnen@...> 2009/11/14

James Edward Gray II wrote:

[#350415] Re: Naming conventions -- was: Re: DRYing a Regex — "David A. Black" <dblack@...> 2009/11/14

Hi --

[#350426] Re: Naming conventions -- was: Re: DRYing a Regex — Marnen Laibow-Koser <marnen@...> 2009/11/14

David A. Black wrote:

[#350359] Trajectories — Thijs Leeflang <t_leeflang@...>

hello,

60 messages 2009/11/13
[#350444] Re: Trajectories — Marnen Laibow-Koser <marnen@...> 2009/11/14

Thijs Leeflang wrote:

[#350446] Re: Trajectories — Eleanor McHugh <eleanor@...> 2009/11/15

On 14 Nov 2009, at 23:40, Marnen Laibow-Koser wrote:

[#350447] Re: Trajectories — Marnen Laibow-Koser <marnen@...> 2009/11/15

Eleanor McHugh wrote:

[#350449] Re: Trajectories — Eleanor McHugh <eleanor@...> 2009/11/15

On 15 Nov 2009, at 00:42, Marnen Laibow-Koser wrote:

[#350451] Re: Trajectories — Marnen Laibow-Koser <marnen@...> 2009/11/15

Eleanor McHugh wrote:

[#350509] Re: Trajectories — Rick DeNatale <rick.denatale@...> 2009/11/15

On Sat, Nov 14, 2009 at 8:19 PM, Marnen Laibow-Koser <marnen@marnen.org> wr=

[#350523] Re: Trajectories — Marnen Laibow-Koser <marnen@...> 2009/11/15

Rick Denatale wrote:

[#350524] Re: Trajectories — Eleanor McHugh <eleanor@...> 2009/11/15

On 15 Nov 2009, at 23:02, Marnen Laibow-Koser wrote:

[#350529] Re: Trajectories — Todd Benson <caduceass@...> 2009/11/16

On Sun, Nov 15, 2009 at 5:32 PM, Eleanor McHugh

[#350532] Re: Trajectories — Eleanor McHugh <eleanor@...> 2009/11/16

On 16 Nov 2009, at 01:12, Todd Benson wrote:

[#350538] Re: Trajectories — Marnen Laibow-Koser <marnen@...> 2009/11/16

Eleanor McHugh wrote:

[#350577] Re: Trajectories — Paul Smith <paul@...> 2009/11/16

On Mon, Nov 16, 2009 at 2:57 AM, Marnen Laibow-Koser <marnen@marnen.org> wr=

[#350593] Re: Trajectories — Marnen Laibow-Koser <marnen@...> 2009/11/16

Paul Smith wrote:

[#350600] Re: Trajectories — Paul Smith <paul@...> 2009/11/16

On Mon, Nov 16, 2009 at 3:18 PM, Marnen Laibow-Koser <marnen@marnen.org> wrote:

[#350602] Re: Trajectories — Marnen Laibow-Koser <marnen@...> 2009/11/16

Paul Smith wrote:

[#350628] Re: Trajectories — Caleb Clausen <vikkous@...> 2009/11/17

On 11/16/09, Marnen Laibow-Koser <marnen@marnen.org> wrote:

[#350629] Re: Trajectories — Marnen Laibow-Koser <marnen@...> 2009/11/17

Caleb Clausen wrote:

[#350645] Re: Trajectories — Caleb Clausen <vikkous@...> 2009/11/17

On 11/16/09, Marnen Laibow-Koser <marnen@marnen.org> wrote:

[#350454] How do I get a random number between two random numbers? — Alex Untitled <somebodydc691n@...>

I want to create a program that asks you to guess a number between two

12 messages 2009/11/15

[#350476] Traversing the contents of a proc (for a DSL) — Siemen Baader <siemenbaader@...>

Hi List,

11 messages 2009/11/15

[#350485] Using activerecord with mysql — Rob Mauchel <rmauchel@...>

Hi All,

13 messages 2009/11/15

[#350526] Newbie question: Defining a numeric type — Seebs <usenet-nospam@...>

I have a type which has a bit of internal magic, but fundamentally, I want

32 messages 2009/11/16

[#350535] Any official name for Ruby's class which makes "class methods"? — Hunt Jon <jona.hunt777@...>

We all know Ruby really doesn't have class methods.

20 messages 2009/11/16
[#350539] Re: Any official name for Ruby's class which makes "class me — Marnen Laibow-Koser <marnen@...> 2009/11/16

Hunt Jon wrote:

[#350682] Re: Any official name for Ruby's class which makes "class me — "David A. Black" <dblack@...> 2009/11/17
[#350689] Re: Any official name for Ruby's class which makes "class me — Marnen Laibow-Koser <marnen@...> 2009/11/17

David A. Black wrote:

[#350698] Re: Any official name for Ruby's class which makes "class me — "David A. Black" <dblack@...> 2009/11/17

[#350590] Google Wave: A new type of "Ruby Quiz" ? — Aldric Giacomoni <aldric@...>

Google Wave is, according to Google, "the new email". It combines email,

21 messages 2009/11/16

[#350594] something went wrong — Dev Tri <divyanshutri@...>

16 messages 2009/11/16

[#350669] What is the difference between the two following pieces of c — Doney Kaka <doneysr@...>

Don't really know where to go with this one, but I gotta know...

10 messages 2009/11/17

[#350679] Class inside a Method Body — Mike Stephens <rubfor@...>

I have a class that works fine if I declare it outside of anything. If

15 messages 2009/11/17

[#350705] Special characters in csv header using fastercsv — John Mcleod <john.mcleod@...>

Hello all,

17 messages 2009/11/17
[#350709] Re: Special characters in csv header using fastercsv — James Edward Gray II <james@...> 2009/11/17

On Nov 17, 2009, at 10:24 AM, John Mcleod wrote:

[#350710] Re: Special characters in csv header using fastercsv — John Mcleod <john.mcleod@...> 2009/11/17

James,

[#350712] Re: Special characters in csv header using fastercsv — James Edward Gray II <james@...> 2009/11/17

On Nov 17, 2009, at 10:38 AM, John Mcleod wrote:

[#350719] Re: Special characters in csv header using fastercsv — John Mcleod <john.mcleod@...> 2009/11/17

I'm not sure if the placement is correct but I'm still getting "Error

[#350810] Exact (LISP-ish) calculations in Ruby? — Aldric Giacomoni <aldric@...>

Has anyone written a gem for exact calculations? The kind one would find

25 messages 2009/11/18

[#350829] Ruby/tk Help Please — Sean Ob <sob4ever33@...>

I am a complete beginner when it comes to programming and i need some

20 messages 2009/11/18
[#350830] Re: Ruby/tk Help Please — Marnen Laibow-Koser <marnen@...> 2009/11/18

Sean Ob wrote:

[#350924] How to strip ruby comments in a ruby line of code? — Alexandre Mutel <alexandre_mutel@...>

Short description : My question is : do you know any available method,

17 messages 2009/11/19

[#350969] Re-opening an existing module and changing a method — Aldric Giacomoni <aldric@...>

"I hear and I forget; I see and I remember; I do and I understand."

11 messages 2009/11/19

[#351010] RubyForge gem index is no more — Tom Copeland <tom@...>

Hello -

14 messages 2009/11/20

[#351084] Distinct Sets (#225) — Daniel Moore <yahivin@...>

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

21 messages 2009/11/21
[#351111] Re: [QUIZ] Distinct Sets (#225) — brabuhr@... 2009/11/21

On Fri, Nov 20, 2009 at 9:23 PM, Daniel Moore <yahivin@gmail.com> wrote:

[#351170] Re: [QUIZ] Distinct Sets (#225) — Rob Biedenharn <Rob@...> 2009/11/22

[#351171] Re: Distinct Sets (#225) — lith <minilith@...> 2009/11/22

> http://gist.github.com/240457

[#351279] Re: Distinct Sets (#225) — Rob Biedenharn <Rob@...> 2009/11/23

On Nov 22, 2009, at 1:51 AM, lith wrote:

[#351137] Order of evaluation and precedence — Seebs <usenet-nospam@...>

In _The Ruby Programming Language_, it is asserted that order of evaluation

11 messages 2009/11/21

[#351245] More on psuedo arrays; Better way? — Ralph Shnelvar <ralphs@...32.com>

Newbie here:

15 messages 2009/11/23
[#351266] Re: More on psuedo arrays; Better way? — Marnen Laibow-Koser <marnen@...> 2009/11/23

Ralph Shnelvar wrote:

[#351267] Re: More on psuedo arrays; Better way? — Brian Candler <b.candler@...> 2009/11/23

Marnen Laibow-Koser wrote:

[#351271] Re: More on psuedo arrays; Better way? — Ralph Shnelvar <ralphs@...32.com> 2009/11/23

BC> Marnen Laibow-Koser wrote:

[#351297] ideas for a "parameter sweep" program? — Diego Virasoro <diego.virasoro@...>

Hello,

11 messages 2009/11/23

[#351328] Warning: instance variable @foo not initialized — Seebs <usenet-nospam@...>

Running some simple tests with Prawn, I am getting thousands of lines

13 messages 2009/11/24

[#351367] Difference between << and += for Strings and Arrays. Bug? — Pieter Hugo <pieter@...>

Hi

14 messages 2009/11/24
[#351373] Re: Difference between << and += for Strings and Arrays. Bug? — Tom Stuart <tom@...> 2009/11/24

2009/11/24 Pieter Hugo <pieter@internext.co.za>:

[#351377] Re: Difference between << and += for Strings and Arrays. Bug? — Pieter Hugo <pieter@...> 2009/11/24

Hi Guys

[#351426] Ruby internals & other questions — Ralph Shnelvar <ralphs@...32.com>

Is there a document or website that describes how Ruby works?

17 messages 2009/11/25

[#351448] Ruby a good choice for CGI? — Nick Dr <nickhannum@...>

Ive been messing around with Ruby for a few weeks now, and I'm fairly

28 messages 2009/11/25
[#351452] Re: Ruby a good choice for CGI? — David Masover <ninja@...> 2009/11/25

On Wednesday 25 November 2009 01:12:19 pm Nick Dr wrote:

[#351453] Re: Ruby a good choice for CGI? — Marnen Laibow-Koser <marnen@...> 2009/11/25

David Masover wrote:

[#351455] Re: Ruby a good choice for CGI? — David Masover <ninja@...> 2009/11/25

On Wednesday 25 November 2009 02:38:32 pm Marnen Laibow-Koser wrote:

[#351456] Re: Ruby a good choice for CGI? — Judson Lester <nyarly@...> 2009/11/25

On Wed, Nov 25, 2009 at 12:52 PM, David Masover <ninja@slaphack.com> wrote:

[#351461] Re: Ruby a good choice for CGI? — David Masover <ninja@...> 2009/11/25

On Wednesday 25 November 2009 03:00:49 pm Judson Lester wrote:

[#351508] Ruby byte access to disk sectors like dd does — Gary Hasson <gary@...>

I have been unable to find any reference to Ruby methods that provide

16 messages 2009/11/26

[#351548] Class variables, instance variables, singleton; Ruby v. C++ — Ralph Shnelvar <ralphs@...32.com>

Newb here coming from C++

31 messages 2009/11/27
[#351570] Re: Class variables, instance variables, singleton; Ruby v. C++ — Steve Wilhelm <steve@...831.com> 2009/11/28

Ralph Shnelvar wrote:

[#351579] Re: Class variables, instance variables, singleton; Ruby v. C++ — "David A. Black" <dblack@...> 2009/11/28

Hi --

[#351586] Re: Class variables, instance variables, singleton; Ruby v. C++ — Ralph Shnelvar <ralphs@...32.com> 2009/11/28

DAB> And of course this is one of the (many) problems with class variables:

[#351572] Local variables can't be accessed from outside, right? — Michael Winterstein <parzival@...>

Hi, I've been trying to figure out metaprogramming and I've mostly got

9 messages 2009/11/28

[#351637] Best way to distribute an app — Omar Campos <hypermeister@...>

Hello everyone,

16 messages 2009/11/29
[#351682] Re: Best way to distribute an app — David Masover <ninja@...> 2009/11/29

On Saturday 28 November 2009 09:03:12 pm Omar Campos wrote:

[#351655] ruby language parser in ruby — Brian Candler <b.candler@...>

I'm looking for a ruby language parser written in ruby, that I can hack

27 messages 2009/11/29

[#351753] have a problem with the loops and variable — Sajjad Po <magicc0d3r@...>

Hi Friends.

20 messages 2009/11/30
[#351756] Re: have a problem with the loops and variable — Michael Linfield <globyy3000@...> 2009/11/30

[#351788] Re: have a problem with the loops and variable — Marnen Laibow-Koser <marnen@...> 2009/12/01

Michael Linfield wrote:

[#351796] Re: have a problem with the loops and variable — Sajjad Po <magicc0d3r@...> 2009/12/01

thank you friends.

[#351798] Re: have a problem with the loops and variable — Sajjad Iran <magicc0d3r@...> 2009/12/01

I want create a program like this.

[#351833] Re: have a problem with the loops and variable — Michael Linfield <globyy3000@...> 2009/12/01

Sajjad Po wrote:

[#351835] Re: have a problem with the loops and variable — Marnen Laibow-Koser <marnen@...> 2009/12/01

Michael Linfield wrote:

[#351840] Re: have a problem with the loops and variable — Michael Linfield <globyy3000@...> 2009/12/01

For something small such as testing lets say a million keys, the

[#351842] Re: have a problem with the loops and variable — Marnen Laibow-Koser <marnen@...> 2009/12/02

Michael Linfield wrote:

[#351755] Problem trying to get a constant with correct scope — Alexandre Mutel <alexandre_mutel@...>

I'm trying to get a constant inside a class (but i have to do it outside

11 messages 2009/11/30

Re: Newbie question: Defining a numeric type

From: Marnen Laibow-Koser <marnen@...>
Date: 2009-11-17 03:45:13 UTC
List: ruby-talk #350640
Seebs wrote:
[...]
>> Right.  But two stats which have the same base and modifiers *are* the 
>> same thing, aren't they?
> 
> I don't think so.  Even if john and mary both have the same base 
> strength,
> and the same modifiers, they're not the same thing -- making john 
> stronger
> doesn't make mary stronger.

I didn't say the same object -- I said the same *thing*.
a = Stat.new(15, -2)
b = Stat.new(15, -2)
It doesn't matter in the slightest whether a.object_id == b.object_id. 
Regardless, a and b are *the same thing* to all intents and purposes -- 
and you can tell that, in part, precisely because the object_id is 
irrelevant.  John's strength isn't the same thing as Mary's strength, 
but that's a very different issue.  The English concept "John's strength 
(in the abstract)" is equivalent to the Ruby method call john.strength. 
The English concept "the concrete value that, for the moment, represents 
John's strength" is equivalent to the return value from that method 
call.  You're confusing the method with its return value.  The 
difference is subtle but important.

English: John's strength, in the abstract, isn't the same thing as 
Mary's strength in the abstract.
Ruby: john.method(:strength) != mary.method(:strength)

English: The current value of John's strength happens to be equal to the 
current value of Mary's strength.
Ruby: john.strength == mary.strength

Does this make sense?

> 
>> That's not the way Ruby references work.  You can obtain a reference to 
>> the object returned by john.strength at a given time, but you can't know 
>> whether john.strength will always return that same object.
> 
> Right -- which is why my initial plan was to commit that, after 
> initialize(),
> john.strength DOES always yield the same object, no matter what changes
> are made to its value.

Why?  There's no point to doing so as far as I can see.  Even if it were 
a Fixnum, it would already be yielding different objects every time it 
changed.  The client should make no assumptions about 
john.strength.object_id.

> 
>>> So when the modifiers change, your solution would be to replace the 
>>> entire
>>> object, duplicating its whole set of modifiers and other state?
> 
>> Yes.  That is the best way of handling value objects -- in fact, it's 
>> the way Ruby handles Fixnums!
> 
> This sounds extremely expensive for an extremely commonplace thing.  In
> an ordinary turn of a game, I might have thirty or forty modifiers which
> change, meaning that I'd be duplicating-but-modifying non-trivial object
> trees thirty or forty times.

It may sound expensive, but it really is the best way of handling value 
objects.  This is how classes like Fixnum, Date, and BigDecimal work. 
(Actually, Fixnum uses the Flyweight pattern under the hood; the others 
might also.)

> 
>> Object 1 is the Fixnum 1, and object 13 is the Fixnum 6.  When the value 
>> of a changes, the variable a holds an entirely different object 
>> reference.
> 
> Yes, I know that.
> 
> But I don't think a stat is a value.  I think it's a complicated model, 
> which
> happens to yield a value.
> 
>> Then maybe a statistic should be composed of several value objects.  I 
>> was operating under the assumption that it's just a base Fixnum and a 
>> Hash containing a few modifier Fixnums.  What else is there?
> 
> History of previous values (in some cases), and the modifiers aren't
> fixnums; they're name/value pairs 

Really?  You're not just doing
@modifiers = {:racial => 2, :class => 1, :armor => -1}?

> probably plus other traits such as
> a duration (some expire, some don't). 

Does that really belong in the values itself?  I'd tend to think not; 
rather, that probably belongs in your event system.

> There will probably be more
> tweaks to that over time.

OK, then this is getting more complex than a simple value object.  If 
you want history, maybe you should have a separate StatValue object, or 
simply a hash.

But if you want history, then the StatValue object or whatever you wind 
up using will probably have to be immutable anyway, so you can be sure 
your history is accurate!

> 
>> From what you've described, Stat isn't large and complicated.  What's 
>> missing from your description?
> 
> As time goes on, stats are expected to be much more complicated.  

Then refactor your design at that time.  Design for what you have now, 
rather than predicting the future.  Remember YAGNI.

> A stat
> will likely have its original starting base value, its highest recorded 
> base
> value, and a set of modifiers (which may change quite often).  Possibly 
> more
> things beyond those.

Since you don't know yet, don't design yet for them (your future plans 
could easily change).  Design a model that works for what you actually 
have, and be ready to change it as necessary.

> 
> So right now, I think it is probably nearly-sanest for me to have it 
> delegate
> nearly everything to the fixnum current value, which really is a value 
> object.
> So it isn't a value, but it delegates to one.
> 
> Basically, anything that has internal state to keep track of which is 
> not part
> of how you use it strikes me as not really being a value, even if it 
> looks
> like one from the outside.

Largely correct, although I can think of exceptions.  You'll probably 
want to break this down into a composed object containing one or more 
value objects.

> 
> That said!
> 
> I am thinking that perhaps it should *present* as immutable -- that is, 
> I
> should not define john.strength = 15 in any way, but rather, if you want 
> to
> ask it to change its value, you have to send it messages.  So instead of
> john.strength += 1, you'd write john.strength.adjust_by(1).

No need.  The former is a lot friendlier.  You can always redefine 
Character#strength= .

> 
> Hmm.  I suppose the thing, then, would be to simply not provide a 
> strength=
> method for the things that have stats.
> 

That strikes me as silly.  There's no reason that the client class 
should care whether your strength= method *really* does an assignment 
operation.

Remember, one of the nice things about OO programming is that interface 
and implementation needn't resemble each other in the slightest.
> -s

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
marnen@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

In This Thread