# If variable == 'value' vs if variable?('value')

**URL:** <https://discourse.chef.io/t/if-variable-value-vs-if-variable-value/13230>\
**Category:** Chef Infra (archive)\
**Created:** [June 27, 2018, 1:36am UTC](https://discourse.chef.io/t/if-variable-value-vs-if-variable-value/13230 "2018-06-27T01:36:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vnodekumar](https://avatars.discourse-cdn.com/v4/letter/v/3d9bf3/32.png) [@vnodekumar](https://discourse.chef.io/u/vnodekumar)\
**Post date:** [June 27, 2018, 1:36am UTC](https://discourse.chef.io/t/if-variable-value-vs-if-variable-value/13230/1 "2018-06-27T01:36:19Z")

</div>

I see that in chef there are two ways to write if condition in a recipe. They both yield the same result. I want to understand what is the difference between the 2 below if condition. Should one of the if be favored over the other one in recipe or attributes or templates – please explain

Case 1 :-

```ruby
if node['platform'] == 'centos'
  Chef::Log.info("In if Condition Platform - #{node['platform']}")
elsif node['platform'] == 'ubuntu'
   Chef::Log.info("In elsif condition - Platform -#{node['platform']}")
else
  Chef::Log.info("In else condition - Platform - #{node['platform']}")
end

```

Case 2 :-

```ruby
if platform?('centos')
  Chef::Log.info("In if Condition Platform - #{node['platform']}")
elsif platform?('ubuntu')
   Chef::Log.info("In elsif condition - Platform -#{node['platform']}")
else
  Chef::Log.info("In else condition - Platform - #{node['platform']}")
end

```

Regards,  
Vinod Kumar

---

<div class="post-metadata">

**Author:** ![coderanger](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/coderanger/32/5_2.png) [@coderanger](https://discourse.chef.io/u/coderanger)\
**Post date:** [June 27, 2018, 1:44am UTC](https://discourse.chef.io/t/if-variable-value-vs-if-variable-value/13230/2 "2018-06-27T01:44:15Z")

</div>

No difference, entirely up to personal style and aesthetic.
