def y we need this in ruby i am beginner of ruby i donot understand what is use of def with out this we make code also i think according to my knowledge it is reserve word

You need the def keyword to define methods in Ruby. The reason that you need a keyword for this is that the creator of Ruby decided that was the most convenient syntax for method definitions.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.