分配不是表达式,在这种情况下只允许使用表达式,我知道它已经讨论过了,但是没有

时间:2019-08-31 17:27:23

标签: android kotlin android-studio-3.4

分配不是表达式,在这种情况下只允许使用表达式,我不知道如何解决此问题

private  fun uploadImageToFirebaswStorage(){
    if (selectedphotoUri = null) return
    val filename = UUID.randomUUID().toString()
     val ref = FirebaseStorage.getInstance().getReference("/images/$filename")

    ref.putFile(selectedphotoUri!!)
        .addOnSuccessListener {
            Log.d("Register","Successfully uploaded image: ${it.metadata?.path}")}

2 个答案:

答案 0 :(得分:1)

#detailview template for quiz {% extends "quiz_app/base.html" %} {% block content %} <article class="quiz-detail"> <h1>{{ object.title }}</h1> <h2>{{ object.question_amount }} Questions</h2> <a class="btn" href="{% url 'quiz-assessment' qid=object.id %}">Start Quiz</a> </article> {% endblock content %} 是一项作业。您最可能希望使用path('quiz_asswssment/?P<int:qid>/', views.assessment, name="quiz_assessment") (两个等号),即等式表达式。

答案 1 :(得分:0)

假设您要按照CommonsWare的说明进行相等性检查,另一种选择是使用通用的Kotlin idiom involving let

  

val值= ...

     

value?.let {       ... //如果不为null,则执行此块}

private  fun uploadImageToFirebaswStorage(){
    selectedphotoUri?.let {
        val filename = UUID.randomUUID().toString()
        val ref = FirebaseStorage.getInstance().getReference("/images/$filename")    
        ref.putFile(selectedphotoUri!!)
          .addOnSuccessListener {
              Log.d("Register","Successfully uploaded image: ${it.metadata?.path}")
          }
     }
}