First time here? Check out the Help page!
1 | initial version |
An Optional is basically something that gets returned when you can't know for sure if something will work on not. It allows you to write code that won't crash, you just have to make sure you test the objects before you do get them
new_sch_idfobj = OpenStudio::IdfObject::load(new_sch)
if new_sch_idfobj.empty?
# Decide what to do if it didn't work
puts "Couldn't load the schedule. Double check your input string"
else
# If it did work, get it
new_sch_idfobj = new_sch_idfobj.get
# Do something with it...
end
You could read up more on the boost documentation if you are interested in knowing exactly why it's a good thing and what advantages it offers.