Is there any way in ruby to create dynamic array names?
correctarrayfiles=Dir.glob(“array_ast_correct_*.rb”).size
correctarrayfiles.times do |num|
correctfiles=findbug.file_exist(“array_ast_correct”)
array+num=findbug.mark_arrary(correctfiles[num])
end
On Sun, Jul 13, 2008 at 08:58:22PM +0900, M. Muzaffar wrote:
arrary0
arrary1
…
…
You are overcomplicating.
correctarrayfiles = Dir.glob(“array_ast_correct_*.rb”).size
corrected_files = (0…correctarrayfiles).map do |num|
correctfiles = findbug.file_exist(“array_ast_correct”)
findbug.mark_arrary(correctfiles[num])
end
Now corrected_files contains an array of whatever findbug.mark_arrary
returns. This is semantically identical to your original code, though I
think there are probably issues with the original code, including typos.
On Sun, Jul 13, 2008 at 08:58:22PM +0900, M. Muzaffar wrote:
arrary0
arrary1
…
…
You are overcomplicating.
correctarrayfiles = Dir.glob(“array_ast_correct_*.rb”).size
corrected_files = (0…correctarrayfiles).map do |num|
correctfiles = findbug.file_exist(“array_ast_correct”)
findbug.mark_arrary(correctfiles[num])
end
Now corrected_files contains an array of whatever findbug.mark_arrary
returns. This is semantically identical to your original code, though I
think there are probably issues with the original code, including typos.
/Muzaffar
–Greg
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.