/ Conditionals / do

How to use do

  • In some scenarios, we need to add do in some places.
  • For example,
  • Here, if current_user.centre_name is not empty and user is not “administrator”
  • then set current_user_centre = current_user.centre_name
  • In such many cases, do plays easy role as much than if condition.
  • Let’s see some easy syntax’s of do condition.
  • <condition_case> can be
  • Example

  • <condition_case> can be
  • cond is value which is need to be compared
  • Example

  • This will out put as
  • Please add your examples also, to update this as much as possible
  • Happy coding!
Most Popular

Leave a Reply

Your email address will not be published.