<p>I want to do some checking in a writer accessor. My first idea was returning a boolean.</p>

<pre><code>class MyClass
  def var=(var)
    @var = var
    # some checking
    return true
  end
end

m = MyClass.new
retval = (m.var = 'foo')

=&gt; "foo"
</code></pre>

<p>Can I set a return value in a writer accessor? If yes, how can I get this value?</p>

I would use set_var(var) instead of what you are trying to do, an attribute writer is assumed to just work. What you are trying to do is nonstandard and non-obvious to the next poor person to use your code. (It may just be yourself) I would throw an exception if bad input is sent or something rather exceptional happens.
You want this behavior
```
```
Correct
>>temp = object.var = 7
=> 7 

Wrong
>>temp = object.var = 7
=> false
```
```
The = operator should always return the value that was passed to it. Ruby uses implicit returns which is uncommon in programming languages. Double check the returns when you use
```
method=()
```
.