# Check empty? of variable for Case/When

**URL:** <https://www.ruby-forum.com/t/check-empty-of-variable-for-case-when/180604>\
**Category:** Rails\
**Created:** [December 22, 2009, 5:21pm UTC](https://www.ruby-forum.com/t/check-empty-of-variable-for-case-when/180604 "2009-12-22T17:21:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![adedip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@adedip](https://www.ruby-forum.com/u/adedip)\
**Post date:** [December 22, 2009, 5:21pm UTC](https://www.ruby-forum.com/t/check-empty-of-variable-for-case-when/180604/1 "2009-12-22T17:21:21Z")

</div>

## I have this:

## case child.name when @collection.location\_tag @article.location = child.content when @collection.content\_tag @article.content = child.content when @collection.docno\_tag @article.docno = child.content when @collection.date\_tag temp\_date = child.content end

is there a way to check whether the @collection.attributes are empty  
or not before to evaluate them in the “When” clause?

–

You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

---

<div class="post-metadata">

**Author:** ![adedip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@adedip](https://www.ruby-forum.com/u/adedip)\
**Post date:** [December 22, 2009, 7:16pm UTC](https://www.ruby-forum.com/t/check-empty-of-variable-for-case-when/180604/2 "2009-12-22T19:16:39Z")

</div>

2009/12/22 adedip [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> ```
> temp_date = child.content
> end
> 
> ```
> 
> * * *
> 
> is there a way to check whether the @collection.attributes are empty  
> or not before to evaluate them in the “When” clause?

I don’t understand what you mean, can you be more explicit?

Colin

–

You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).
