# Void value expression

**URL:** <https://www.ruby-forum.com/t/void-value-expression/183192>\
**Category:** JRuby\
**Created:** [February 9, 2010, 8:56pm UTC](https://www.ruby-forum.com/t/void-value-expression/183192 "2010-02-09T20:56:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [February 9, 2010, 8:56pm UTC](https://www.ruby-forum.com/t/void-value-expression/183192/1 "2010-02-09T20:56:11Z")

</div>

I noticed that this code:

def go  
a = true  
b = nil  
return a.nil? or b.nil?  
end  
puts go

actually returns false in jruby–I would have expected it to return  
true, and in MRI (1.8.6, 1.9.1), it yields:

bad.rb:4: void value expression

(so I suppose if it wants to match MRI, it should raise that error).  
Is this a bug?  
Thanks.  
-r

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [February 9, 2010, 9:38pm UTC](https://www.ruby-forum.com/t/void-value-expression/183192/2 "2010-02-09T21:38:33Z")

</div>

I think the problem has to do with the low operator precedence of the  
or operator.

The following code works:

def go  
a = true  
b = nil

return (a.nil? or b.nil?)

end  
puts go

But I agree that the different implementations should at least throw  
the same error message.

Regards  
Roger

Am 09.02.2010 um 20:56 schrieb Roger P.:

> actually returns false in jruby–I would have expected it to return
> 
> * * *
> 
> To unsubscribe from this list, please visit:
> 
> [http://xircles.codehaus.org/manage\_email](http://xircles.codehaus.org/manage_email)

* * *

To unsubscribe from this list, please visit:

```
http://xircles.codehaus.org/manage_email

```

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [February 9, 2010, 10:40pm UTC](https://www.ruby-forum.com/t/void-value-expression/183192/3 "2010-02-09T22:40:02Z")

</div>

Hi Roger and Roger,

I agree that this seems to be a JRuby compatibility issue and it is  
definitely worth filing a JRuby issue for that, could you guys file  
one?

Ideally, we should have RubySpec test for that as well.

Thanks,  
–Vladimir

On Tue, Feb 9, 2010 at 9:38 PM, Roger G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > –
> 
> * * *
> 
> To unsubscribe from this list, please visit:
> 
> [http://xircles.codehaus.org/manage\_email](http://xircles.codehaus.org/manage_email)

* * *

To unsubscribe from this list, please visit:

```
http://xircles.codehaus.org/manage_email

```

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [February 10, 2010, 12:28am UTC](https://www.ruby-forum.com/t/void-value-expression/183192/4 "2010-02-10T00:28:12Z")

</div>

> But we still need a JRuby bug filed! 🙂

[http://jira.codehaus.org/browse/JRUBY-4549](http://jira.codehaus.org/browse/JRUBY-4549)

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [February 9, 2010, 11:28pm UTC](https://www.ruby-forum.com/t/void-value-expression/183192/5 "2010-02-09T23:28:38Z")

</div>

On Tue, Feb 9, 2010 at 10:39 PM, Vladimir S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Ideally, we should have RubySpec test for that as well.

So, I just added RubySpecs for this case:  
[http://github.com/rubyspec/rubyspec/commit/38bd0643c3e7bdba0aecf5eb91b0be9b56b5b5d7](http://github.com/rubyspec/rubyspec/commit/38bd0643c3e7bdba0aecf5eb91b0be9b56b5b5d7)

But we still need a JRuby bug filed! 🙂

Thanks,  
–Vladimir

> > return (a.nil? or b.nil?)  
> > Roger
> > 
> > > puts go  
> > > -r
> > 
> > * * *
> > 
> > To unsubscribe from this list, please visit:
> > 
> > [http://xircles.codehaus.org/manage\_email](http://xircles.codehaus.org/manage_email)

* * *

To unsubscribe from this list, please visit:

```
http://xircles.codehaus.org/manage_email

```
