From: Daniel N Date: 2007-02-21T09:20:26+09:00 Subject: Re: Checking what a method has returned ------=_Part_47210_10954687.1172017220749 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 2/21/07, Chris Gallagher wrote: > > Hi, > > Im looking for a way of checking whether a method has returned true or > false. > > for example i have an want to start off by checking if an image is > already stored locally by calling " def checkCache". If the image is > already there it will simply come back the process is complete. If it > isnt there already it will need to call another method which will be > called "downloadImage". > > What I have for this at the moment is far from complete so feel free to > change it around: > > > def index > > @domains = ['yahoo.com','google.com'] > domains_length = @domains.length > > domains_length.times { |i| > ######## if checkCache finds that there is no image present then it > needs to #########proceed to the next method which would be > downloadImage. > checkCache(@domains[i]) > downloadImage(@domains[i]) > end > > } > end If checkCache returns true of false then use inline if / unless. downloadImage(@domains[i] unless checkCache(@domains[i]) All on one line... Noice ------=_Part_47210_10954687.1172017220749--