assign values passed to a function to a variable by their type and optional by their index