# Flag this message private class methods- functionality or shortcoming?

**URL:** <https://www.ruby-forum.com/t/flag-this-message-private-class-methods-functionality-or-shortcoming/139961>\
**Category:** Ruby\
**Created:** [June 9, 2008, 4:17pm UTC](https://www.ruby-forum.com/t/flag-this-message-private-class-methods-functionality-or-shortcoming/139961 "2008-06-09T16:17:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 9, 2008, 4:17pm UTC](https://www.ruby-forum.com/t/flag-this-message-private-class-methods-functionality-or-shortcoming/139961/1 "2008-06-09T16:17:45Z")

</div>

My apologies for resending but there were some formatting errors in the  
code.

I just switched to Ruby and came across it.  
If we have to make a class method private then we should write it as:

class Abc

```
class<<self
    private
    def fun
        p "hello"
    end
end

```

end

But if we write as:

class Abc

```
private
def self.fun
    p "hello"
end

```

end

then the class method is not private but behaves as public.

So, is it a carefully designed functionality? If so, then what is the  
thinking behind it?  
OR any other reasons behind it?  
Somebody told me that ruby encourages to define class methods the first  
way.  
But I think that if you are giving more than one methods to do a thing,  
then all should function the same way.

Thanks and Regards,  
Amit
