A Ruby code that's demonstrating creating a struct.
1: myTestArray = []2:3: myTestArray[0] = 'Mr Peer Zvika 42'4:5: myTestArray[1] = 'Mrs Peer Dalit 42'6:7: puts myTestArray8:9: Persons = Struct.new(:title, :Family, :name, :age)10:11: personsArray = []12:13: myTestArray.each do |nextOne|14: title, Family, name, age = nextOne.chomp.split(' ')15:16: personsArray << Persons.new(title, Family, name, age)17: end18:19: puts personsArray20:
אין תגובות:
הוסף רשומת תגובה