Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I write instance or class method inside if condition?

Can I write something like this inside model ?

if true
  def instance_method
  end

  def class_method
  end
end
like image 718
krunal shah Avatar asked May 09 '26 05:05

krunal shah


1 Answers

As far as I know if statements do not introduce scope in Ruby 1.9.2 so you can use statements like that

like image 97
Bohdan Avatar answered May 11 '26 17:05

Bohdan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!