Skip to main content

class in Ruby

"class is a blueprint of an Object" What's that mean? Object and class,An object is a package which are called at the runtime which cannot modified at run time,So what we defined in class are converted to object and this object are called at runtime execution.
so we can call class as a blue print of an object.In class we actually designing our program for the output what we required.We can include method inside the class so methods need variable declaration for their operations,Programmers can decide these methods and variables should be kept as private for outside the class.All kinds of designing are done inside the class.Lets look at an example how class and object are created at ruby.
To crate a class in ruby, use the key word class and class name should start with capital alphabetic letter and to create a object use the keyword new

In this program Animal is the class and dog is the method inside method there is a message of string type,When we call this class as object and from the object we call the method,It will print "I am Barking". is the object creation and new method is assigned to barking.The new object of animal is created with address like <0x000000111> something like that.So object is created now we can call the method the created object using "" .


Popular posts from this blog

creating first go program

for creating go program open your editor and paste this code, and save it as filename.go for example helloworld.go

package main import "fmt" func main() { fmt.Println("Hello, 世界") }
I will explain these codes in details for now , we will look how to run these code.

to run type go run helloworld.go  in terminal , we get

you can try golang online as well , golang