Java中的Lambda:变量与类字段

时间:2019-02-12 15:19:05

标签: java variables lambda field

lambda中的变量必须有效地最终确定。好。 但是,为什么在下面的示例代码中允许分配类字段值?

堆和堆栈是否引起这种差异?为什么?

// ON AUTH STATE CHANGES

firebase.auth().onAuthStateChanged(function(user) {
    if (user) {

        // USER IS SIGNED IN
      document.getElementById("showIfNotLogIn").style.display = "none";
      document.getElementById("onUserLogin").style.display = "block";
        } else {
      // No user is signed in.
      document.getElementById("showIfNotLogIn").style.display = "block";
     document.getElementById("onUserLogin").style.display = "none";
    }
  });

  //THIS PART IS WORKING FOR SURE

function letMeLogin(){


let usernaming = document.getElementById("userNameForLogin").value;
let userpasswording = document.getElementById("userPasswordForLogin").value;

firebase.auth().signInWithEmailAndPassword(usernaming, userpasswording).catch(function(error) {
    // Handle Errors here.
    var errorCode = error.code;
    var errorMessage = error.message;
    // ...

    window.alert(`Alert: ${errorMessage}`);
  });

}

//THIS IS THE PART FOR LOGOUT WHICH IS GIVING THE ERROR

    function logOut(){

  firebase.auth().signOut().then(function() {
      // Sign-out successful.
    }).catch(function(error) {
      // An error happened.
   });
  }

0 个答案:

没有答案