title: How can I convet MutableMap<String, Any?> to vararg values: Pair<String, Any?>?
body: <p>The following code is from "Kotlin for Android Developers", you can access it at <a href="https://github.com/antoniolg/Kotlin-for-Android-Developers" rel="noreferrer">https://github.com/antoniolg/Kotlin-for-Android-Developers</a></p>
  
  <p>In order to insert a row data into <code>CityForecastTable.NAME</code>, I have to pass a <code>vararg</code> values by <em>Source Code</em> <code>fun SQLiteDatabase.insert</code></p>
  
  <p><strong>1:</strong>  The author make a extension <code>toVarargArray()</code> to convert a <code>MutableMap&lt;String, Any?&gt;</code> to <code>Pair&lt;String, Any?&gt;</code>, I don't know whether there is a better way to do that. Do I need to use a extension function?</p>
  
  <p><strong>2:</strong>  The author have to use the code <code>it.value!!</code> in Code C , I don't know if the code <code>fun &lt;K, V : Any&gt; Map&lt;K, V?&gt;.toVarargArray(): Array&lt;out Pair&lt;K, V?&gt;&gt; = map({ Pair(it.key, it.value) }).toTypedArray()</code> is right?</p>
  
  <p><strong>3:</strong> I don't know whether the app will crash when I insert a row data of which a column include null value.</p>
  
  <pre><code>import org.jetbrains.anko.db.*
  class ForecastDb(private val forecastDbHelper: ForecastDbHelper = ForecastDbHelper.instance,
                   private val dataMapper: DbDataMapper = DbDataMapper()) : ForecastDataSource {
  
      fun saveForecast(forecast: ForecastList) = forecastDbHelper.use {           
  
           //dataMapper.convertFromDomain(forecast) will return CityForecast object 
           with(dataMapper.convertFromDomain(forecast)) {
              insert(CityForecastTable.NAME, *map.toVarargArray())           
          }
      }
  
  }
  
  
  class CityForecast(val map: MutableMap&lt;String, Any?&gt;, val dailyForecast: List&lt;DayForecast&gt;) {
      var _id: Long by map
      var city: String by map
      var country: String by map
  
      constructor(id: Long, city: String, country: String, dailyForecast: List&lt;DayForecast&gt;)
              : this(HashMap(), dailyForecast) {
          this._id = id
          this.city = city
          this.country = country
      }
  }
  </code></pre>
  
  <p><strong>Code C</strong></p>
  
  <pre><code>fun &lt;K, V : Any&gt; Map&lt;K, V?&gt;.toVarargArray(): Array&lt;out Pair&lt;K, V&gt;&gt; =
          map({ Pair(it.key, it.value!!) }).toTypedArray()
  </code></pre>
  
  <p><strong>Source Code</strong></p>
  
  <pre><code>fun SQLiteDatabase.insert(tableName: String, vararg values: Pair&lt;String, Any?&gt;): Long {
      return insert(tableName, null, values.toContentValues())
  }
  </code></pre>