2018年4月26日 星期四

little funny learn from ruby private

I usually make my private methods like this:

```
class Foo
  private

  def private_method
  end
end
```

However, there is inline-style private method like this:

```
class Foo
  private def private_method
  end

  def puiblic_method_yo!
  end
end
```

Additionally, attr_reader is also available for inline-style private method:

```
class Foo
  private attr_reader :bar
end
```

So fancy, isn't it? lol

沒有留言:

張貼留言