DrSchool Learn coding, fast.
EN AR BN CS DE EL Search

Classes / Objects — Example 108

Quick explanation + ready code for: Classes / Objects.

Ruby Classes / Objects Back to examples
Back to language
Syntax: Classes / Objects in Ruby. ID: #108

Code

class User{ constructor(name){this.name=name} hi(){return "Hi "+this.name} }
console.log(new User("A").hi());

Notes

You can copy this snippet and adapt it. For advanced, add real-world inputs, edge cases, and tests.