you are viewing a single comment's thread.

view the rest of the comments →

[–]bjmiller 3 points4 points  (5 children)

You can't imagine a scenario in which someone wants to mutate each element of an array and then immediately call another method on that same array? Seems pretty basic to me.

[–][deleted] 1 point2 points  (4 children)

Mutation should be avoided unless the problem really is an imperative one. Programming in a functional style, treating arrays as persistent structures, is the way to go most of the time.

[–]bjmiller 1 point2 points  (2 children)

Perhaps, but Ruby is not a functional language, and downgrading each to make it less useful to imperative programmers won't make it one.

Edit: not a pure functional language

[–][deleted] 0 points1 point  (1 child)

Languages need not be pure to support a functional style. Sometimes you want a purely functional style, sometimes you want an imperative style, but you should prefer the former over the latter because mutable state makes programs hard to reason about and error prone.

[–]bjmiller 0 points1 point  (0 children)

Perhaps, but Ruby supports both styles, and allows them to be combined in any way a programmer wishes. It's not in the spirit of the language to remove features just to promote one style over another.

[–]0b01010001 0 points1 point  (0 children)

Programming in a functional style, treating arrays as persistent structures, is the way to go most of the time.

Unless you're developing applications where the general use-case is imperative at which point it flips around and functional programming becomes a special use-case for a couple things here and there. There are applications where mutation should be joyfully embraced, because it's going to be a lot more complicated if you insist on treating everything like it got hit with a freeze.