Re: type fruit(sequence unknown_fruit)

new topic     » goto parent     » topic index » view thread      » older message » newer message
vmars said...

From A Beginners Guide to Euphoria:

type fruit(sequence unknown_fruit)
sequence valid_fruit
valid_fruit = {"bananas", "apples", "oranges", "pears"}
return find(unknown_fruit, valid_fruit)
end type

This defines the fruit type so you can use it later

said...



This is wierd to me.
It would make more sense like this:

fruit_check = "pears"
fruit fruit_check
puts(1, "Program Run Completed\n")
or
fruit_check = "pears"
fruit_check = fruit(fruit_check)
puts(1, "Program Run Completed\n")


Please, Why is it structured like this?
Thanks!

using it later

fruit fruit_check                --defining a variable of type fruit 
 
if fruit("pears") then           --test of pears is a fruit 
    puts(1, "Valid fruit!\n") 
    fruit_check ="pears"         --fruit check can now be "pears" 
else  
    puts(1, "Not a valid fruit!\n") 
    fruit_check = "pears"        --fruit_check can't be "pears" - will crash the program 
                                 --add pears to the list of valid fruits 
end if 
 
 

Chris

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu