hey everyone i want to split the array.This is the out put when i
print array "Khamar Md,2 hrs: 5 min,Accounts,Gandhinagar" and i wanna
split them and i want to print them in different columns in a table.
<%x=Array.new%>
<%x=@late_commers.split(",")%>
<% x.each do |late_commer| %>
<td><%= late_commer.at(0) %></td>
<%end%>
when i use the about code i get Khamar Md,2 hrs: 5
min,Accounts,Gandhinagar in one column only . i want them in different
columns like
Name | Time | Dept | Loc
This works for me. No need to declare x as Array.new.. that's going
to happen when you assign it the value of late_commers.split
Why the late_commer.at(0) if late_commer is the value of an individual
string? Are you sure that late_commers is a string to begin with?
irb(main):001:0> x = "This, is, a, test"
=> "This, is, a, test"
irb(main):002:0> y = x.split(",")
=> ["This", " is", " a", " test"]
irb(main):003:0> y.each do |z|
irb(main):004:1* puts z
irb(main):005:1> end
This
is
a
test
=> ["This", " is", " a", " test"]
irb(main):006:0>