# Is this considered functional?

**URL:** <https://www.ruby-forum.com/t/is-this-considered-functional/169875>\
**Category:** Ruby\
**Created:** [June 9, 2009, 9:38pm UTC](https://www.ruby-forum.com/t/is-this-considered-functional/169875 "2009-06-09T21:38:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![remcoh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c37758/32.png) [@remcoh](https://www.ruby-forum.com/u/remcoh)\
**Post date:** [June 9, 2009, 9:38pm UTC](https://www.ruby-forum.com/t/is-this-considered-functional/169875/1 "2009-06-09T21:38:46Z")

</div>

I am reading stuff about functional programming in ruby.

what i do more lately is this:

var = ? “val1” : "val2:

instead of:  
 ? var=“val1” : var=“val2”

is the first line also an example of functional programming?

---

<div class="post-metadata">

**Author:** ![remcoh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c37758/32.png) [@remcoh](https://www.ruby-forum.com/u/remcoh)\
**Post date:** [June 9, 2009, 10:31pm UTC](https://www.ruby-forum.com/t/is-this-considered-functional/169875/2 "2009-06-09T22:31:14Z")

</div>

Remco Hh [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> I am reading stuff about functional programming in ruby.
> 
> what i do more lately is this:
> 
> var = ? “val1” : "val2:
> 
> instead of:  
> ? var=“val1” : var=“val2”
> 
> is the first line also an example of functional programming?

This might be considered a syntactic detail.

Functional programming is characterized by the use of mathematic  
functions as a model of computation, which avoids state and mutable  
data.

There’s no notion of mutation in the usual mathematical objects (it’s  
possible to modelize state and mutation mathematically, but it  
involves more complex structures).

So, if you assign only once each variable var, it can be considered as  
a binding, that is like a mathematical “variable”.

When we say mathematically “let y0 be f(0)”, the variable y0 doesn’t  
change (it’s a constant really).

Notice that avoiding state is rather antinomic to Object Oriented  
Programming, since objects are defined by the encapsulation of both  
state and program. If you remove state, there remains only program,  
that is functions.

Well, you may keep objects, but without mutation, that is you may bind  
values to an object instance variable only at initialization time, and  
once the object is created, it mustn’t change.

[http://groups.google.com/group/comp.lang.ruby/search?group=comp.lang.ruby&q=functional+group%3Acomp.lang.ruby+&qt\_g=Search+this+group](http://groups.google.com/group/comp.lang.ruby/search?group=comp.lang.ruby&q=functional+group%3Acomp.lang.ruby+&qt_g=Search+this+group)
