Learning abstract concepts through concrete examples may promote learning at the cost of inhibiting transfer. The present study investigated one approach to solving this problem: systematically varying superficial features of the examples. Participants learned to solve problems involving a mathematical concept by studying either superficially similar or varied examples. In Experiment 1, less knowledgeable participants learned better from similar examples,while more knowledgeable participants learned better from varied examples. In Experiment 2, prior to learning how to solve the problems, some participants received a pretraining aimed at increasing attention to the structural relations underlying the target concept. These participants, like the more knowledgeable participants in Experiment 1, learned better from varied examples. Thus, the utility of varied examples depends on prior knowledge and, in particular, ability to attend to relevant structure. Increasing this ability can prepare learners to learn more effectively from varied examples.