0

Simple question:

var x = '<%=Request["myvar"]%>' || null;

why does resharper say "Code is heuristically unreachable", When this seems to work just fine?

Rafael Herscovici
  • 16,558
  • 19
  • 65
  • 93

1 Answers1

1

You are setting x to a string value so it will never equal null. Therefore the || null is unreachable.

This should help: What does the construct x = x || y mean?

Lauren Rutledge
  • 1,195
  • 5
  • 18
  • 27
  • as per my comment, if the string is empty, i do get null. if it was unreachable, why do i get the null result when the string is empty? – Rafael Herscovici Dec 05 '13 at 15:01