title: Swift; Initialization of immutable value was never used
body: <p>I have this simple piece of <code>Swift</code> code:</p>
  
  <pre><code>let message = "This is a test"
  
  if message.range(of:"test") != nil {
      let message = "Changed string"
  }
  
  print(message)
  </code></pre>
  
  <p>What I want to do: If string <code>message</code> contains the string <code>test</code>, change it to <code>Changed string</code>. Else keep it unchanged.</p>
  
  <p>I'm getting the following warning:</p>
  
  <blockquote>
    <p>Initialization of immutable value 'message' was never used; consider
    replacing with assignment to '_' or removing it</p>
  </blockquote>
  
  <p>for line</p>
  
  <pre><code>let message = "Changed string"
  </code></pre>
  
  <p>Also, printed output is still <code>This is a test</code> instead of expected <code>Changed string</code>.</p>
  
  <p>What am I doing wrong?</p>