I am comparing strings from a text file, but for some reason they never match. If I do it in ruby it is very easy, but in processing I can not get it to work.
this is the ruby code that works:
f=File.open("priceMap_current_new.txt")
f.each do |str|
arrstr=str.split(";")
if arrstr.length==1
puts arrstr[0].inspect if arrstr[0]=="next\n"
end
end
Now here’s the processing version that doesn’t work, actually it doesnt even work without reading from file:
String[] mystr={"number;zero","number;one","number;two","number;three","number;four"};
for(int i=0;i<mystr.length;i++){
String[] numbers=split(mystr[i],";");
if(numbers[0]=="number"){
println("shoooooooooooooooooout");
}
}
Additionally I would like to ask if there’s a way to inspect elements like in ruby, its very handy, because if I print pts[0] in processing I get “next” when its actually “next\n”
or also how to check datatypes in processing. Thanks!
Use
if (numbers[0].equals("number"))From: Processing doco