Skip to content

Instantly share code, notes, and snippets.

@evizitei evizitei/Person.cs
Created Oct 14, 2013

Embed
What would you like to do?
C# to Ruby
public class Person
{
// Field
public string name;
// Constructor that takes no arguments.
public Person()
{
name = "unknown";
}
// Constructor that takes one argument.
public Person(string nm)
{
name = nm;
}
// Method
public void SetName(string newName)
{
name = newName;
}
}
class Person
attr_reader :name
def initializer(nm = 'unknown')
@name = nm
end
def set_name(new_name)
@name = new_name
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.