# How avoid error message with Range?

Evaluating

     Range[1, n] /. n -> 3


produces an error message

 range::range: Range specification in Range[1,n] does not have appropriate bounds


even though it does produce correct output {1, 2, 3}.

What's a good way to accomplish the same thing while avoiding the error message?

• ReplaceAll or /. does not hold its arguments, so Range[1, n] is evaluated with symbolic n first. Sep 22 '15 at 19:29
• Because it first evaluates Range[1,n] which is not very miningful and only then substitutes n->3 With[{n=3},Range[1,n]] could be more appropriate or R[n_]:=Range[1,n]; R[3] or as suggested by @ilian Sep 22 '15 at 19:32
• Yet Attributes[ReplaceAll] gives no Hold attributes! Sep 22 '15 at 19:57
• @murray that is exactly what illian says... Sep 22 '15 at 20:19
• Sorry, I missed the "no" in illian's comment. All is clear now, thanks. Sep 22 '15 at 21:22

myRange[x__?NumericQ] := Range[x]

{1, 2, 3}