M
M
Maxim2017-02-20 01:16:29
ruby
Maxim, 2017-02-20 01:16:29

How to create an empty object?

How to create an empty object in Ruby.
You need something like this, but you don’t want to create a class for such actions.

a = Object.new
a.variable = '1'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2017-02-20
@1kachan

require 'ostruct'
a = OpenStruct.new
a.variable = 1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question