From: koichirose Date: 2008-05-26T05:19:35+09:00 Subject: A simple newbie question (arrays and strings) Today I started programming in ruby. Here's what I managed to do so far: string = Dir.entries(".") string.delete_at(0) string.delete_at(0) 1. I get a list of files 2-3. I delete the first two elements ('.' and '..') Now my files are all like "something - some other thing" I want to split them: string.each do |s| puts s.split("-")[0] end So it outputs the "something" part in my filenames. Now I'd like to remove duplicate entries (.uniq method right?). Can it be done in a single line? If not, how do i get an array containing only the "something" part to work on with .uniq? I tried with some loops, to create a new array with the splitted string in it, but my PHP approach doesn't work: i = 0 for i in string splitted[i] = i.split("-")[0] i += 1 end Thank you!